Bug 24812

Summary: Optimizer creates infinite loop with -fno-strict-aliasing
Product: gcc Reporter: Chris Newbold <cnewbold>
Component: rtl-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: cnewbold, gcc-bugs
Priority: P3    
Version: 3.4.4   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Chris Newbold 2005-11-11 20:51:53 UTC
The following test program goes into an infinite loop when compiled with -O2 and -fno-strict-aliasing but works correctly if -fno-strict-aliasing is omitted.

$ g++-3.4 -g -O2 -fno-strict-aliasing -o loop loop.C

// loop.C
class DummyType
{
public:
    ~DummyType() { }
};

class Foo
{
public:
    Foo() : X0(0), X4(0) { }
    int X0, X1, X2, X3, X4;
};

int main(int, char**)
{
    {
        Foo f;
	DummyType d;
    }

    Foo f2;

    bool done(false);

    while (!done) {
	if (f2.X4 != 0) f2.X4 = 0;
	else done = true;;
    }

    return 0;
}

-----

Reading specs from /usr/lib/gcc/i486-linux/3.4.4/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --disable-werror i486-linux
Thread model: posix
gcc version 3.4.4 20050314 (prerelease) (Debian 3.4.3-13)
Comment 1 Andrew Pinski 2005-11-11 20:56:56 UTC

*** This bug has been marked as a duplicate of 24804 ***