http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55839
Bug #: 55839 Summary: Inefficiency with array constructor Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: tkoe...@gcc.gnu.org This idiom subroutine foo(a,b,c,n) integer, intent(in) :: n real, intent(in), dimension(n) :: a,b real, intent(out), dimension(2*n) :: c c(1:2*n) = [a(1:n), b(1:n)] end subroutine foo builds an array using malloc and copies the data two times. It would be better to express this as c(1:n) = a(1:n) c(n+1:2*n) = b(1:n) Looks like a job for front-end optimization; it would be a bit hard to expect the middle-end to optimize away all the calls to malloc etc.