This is the mail archive of the 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++/24804] New: Produces wrong code

Compile the following program (minimized from a larger context) with
'g++ -O3 -fno-strict-aliasing foo.cpp' (on a Linux i386 32-bit machine
with gcc 3.4.4)

class DummyType
    inline DummyType() { }
    inline ~DummyType() { }

class Foo
    Foo() : X0(0), X4(0) { }

    int X0, X1, X2, X3, X4;

int main()
        Foo f;

    Foo f2;
    while (1) {
        if (f2.X4 != 0) {
           f2.X4 = 0;
        } else {

  return 0;

It will hang if you execute it.

It does not hang if you do _one_ of the following things:

- Compile with -O1 (instead of -O3)
- Remove compiler flag -fno-strict-aliasing
- Replace all occurrences of 'f2.X4' with 'f2.X3'
- Remove the statement 'DummyType();'
- Remove the statement 'Foo f;'

           Summary: Produces wrong code
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: abottema at mathworks dot com
 GCC build triplet: ix86-linux
  GCC host triplet: ix86-linux
GCC target triplet: ix86-linux

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