https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80701
Bug ID: 80701 Summary: gfortran ignores dead code after return statement Product: gcc Version: 6.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: gustavo.hime at mpimet dot mpg.de Target Milestone: --- Created attachment 41336 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41336&action=edit bug.f90 Compiling the attached code with "gfortran -c bug.f90" generates no warnings. However, if one inspects the object file, there is no mention of the "undefined" symbol that is used in the code. If one comments out the RETURN statement, it still compiles without warnings, but the symbol is there. This behaviour happens independently of the value of -On, both on 5.2.0 and 6.2.0. For the record, NAG and Intel behave similarly, but I would like to have the compiler throw at least warnings for unreachable code. The compiler does generate a warning about the implicit interface if -Wimplicit-interface is turned on explicitly. I would suggest this should be on by default with -Wall on any source not written in F77, or when a higher standard is enforced.