I am compiling with g++ on a 64 bit Ubuntu OS.  I spent days trying to find out
why my programs kept crashing.  I found that when using O2 optimizations the
problem is there, when using O1 it is not a problem.

I am not using any compiler options other than stripping symbols, hiding
warnings, and O2.

Here is a very simple test case that causes the bug every time.

void RefTest(byte*& p)
{
        ++p;
}
void RefTest(char*& p)
{
        ++p;
}

char* c= "0123";
char* p= c;
RefTest((byte*&)p);
cout << p << endl; // 0123
RefTest(p);
cout << p << endl; // 123

return 0;


-- 
           Summary: O2 causes invalid code
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew at warnux dot com


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

Reply via email to