[Bug c++/38297] New: O2 causes invalid code
andrew at warnux dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 28 00:30:00 GMT 2008
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
More information about the Gcc-bugs
mailing list