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 middle-end/12342] New: [tree-ssa] staticvariables in static functions are incorrectly "optimized" away


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: [tree-ssa] staticvariables in static functions are
                    incorrectly "optimized" away
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gerald at pfeifer dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i386-unknown-freebsd4.8

Consider the following example x.c:

  static bool checkWC(bool newstate) {
    static bool state=false;

    if (state==false)
        state=newstate;

    return state==newstate;
    }

  int main() {
    return checkWC(false);
    }

If compiled with -O3, gcc incorrectly "optimizes" away the state variable in
the function.

  % gccvs -O3 x.c
  /var/tmp//ccVmxe3H.o: In function `main':
  /var/tmp//ccVmxe3H.o(.text+0x7): undefined reference to `checkWC(bool)::state'
  /var/tmp//ccVmxe3H.o(.text+0x14): undefined reference to`checkWC(bool)::state'
  collect2: ld returned 1 exit status


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