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

            Bug ID: 68641
           Summary: undefined variables implicitly considered to be zero
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Joost.VandeVondele at mat dot ethz.ch
  Target Milestone: ---

This is an enhancement request. Using -O1 and higher, undefined variables are
considered equal to 0 in optimization. This leads to code compiling at -O1 but
failing to compile at -O0, for example :

> cat test.f90
  INTEGER :: i
  INTEGER, POINTER :: foo
  IF (i/=0) CALL link_error
  IF (ASSOCIATED(foo)) CALL link_error
END

another disadvantage is that e.g. using valgrind, the above program will not
fail when compiled at -O1. Only at -O0 these cases will be found (leading to
much longer testing times).

Using -Wmaybe-uninitialized is not a real solution, there are just too many
false positives (I'm not aware of a -Wmust-be-uninitialized, which would be
valuable).

So, ideally no optimization is done based on an assumed value.

Reply via email to