This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/37063] New: missing optimiation on unreachable code


I would expect gcc to optimize away the unreachable code in both functions
below but only in the first one is it eliminated. In addition, even though
the call to f1() in f3() can never be executed the compiler issues no
warning.

$ cat -n t.C && g++ -Wunreachable-code -O3 -S t.C
     1  void f1 ();
     2
     3  int f2 ()
     4  {
     5      int x = 0;
     6
     7      if (x == 0) return 0;
     8      f1 ();
     9
    10      return 1;
    11  }
    12
    13  int f3 ()
    14  {
    15      static int x;
    16
    17      if (x == 0) return 0;
    18      f1 (); 
    19
    20      return 1;
    21  }
    22
t.C: In function ?int f2()?:
t.C:8: warning: will never be executed


-- 
           Summary: missing optimiation on unreachable code
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37063


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]