http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38318
--- Comment #10 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> --- (In reply to Marc Glisse from comment #9) > > Ok. If you used __builtin_abort instead of _gfortran_os_error, I think my > current patch would handle it. It is hard for gcc to guess that > _gfortran_os_error is safe. For the Fortran FE people (not me, I'm a user), but _gfortran_os_error should have an attribute like 'abort' or 'noreturn'. However, the compiler should also be able to figure out this can never be called (if B is 'allocated on the stack') in this subroutine. > Er, no, I missed the call to s2. I would also need some attribute on s2 so > the compiler knows that s2 doesn't do anything too weird. Actually, in Fortran, S2 can't do anything 'weird' with B, in the sense that your optimization should certainly apply. Not so sure about the correct terms here, but in approximate C-speak, B 'as a pointer' is guaranteed to be pointing to exactly the same address, nothing has happened to its target, and no pointer can be pointing to whatever B was pointing to....