https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80701

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
                 CC|                            |tkoenig at gcc dot gnu.org
          Component|fortran                     |middle-end
             Blocks|                            |46476
            Summary|gfortran ignores dead code  |Option for generating link
                   |after return statement      |symbol for functions
                   |                            |removed by DCE
           Severity|normal                      |enhancement

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Gustavo Hime from comment #4)

> However, since the object code does not contain the dead part, and hence no
> symbols are resolved at link-time, many of the potential problems remain,
> i.e., the code will still compile and link in spite of there being a
> function call to a symbol that isn't defined.

This one really depends on personal preference.

Personally, I like adding statemens like

  parameter, logical :: debug = .false.

  ...
  if (debug) then
     call some_routine_for_debugging_stuff
  end if

Removing dead code including function calls is something that is done in the
middle-end. Here is an equivalent C test case:

$ cat undef.c
void foo(void);

int main()
{
   if (0)
      foo();
   return 0;
}
$ gcc -Wall -Wextra undef.c
$ 

I don't think we will get agreement to turn on such a warning
by default. However, a request for an option that warns in such
a case is justified.

Confirming as enhancement request.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46476
[Bug 46476] Missing Warning about unreachable code after return

Reply via email to