[Bug tree-optimization/49873] New: Optimizer regression
abenea at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jul 27 16:58:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49873
Summary: Optimizer regression
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: abenea@gmail.com
Test code:
typedef struct {
char *ptr;
} S;
void f1(char* data) {
S s;
s.ptr = 0;
char *same_data = s.ptr + (data - s.ptr);
same_data[0] = 1;
}
int main() {
char c;
f1(&c);
if (c != 1)
return 1;
return 0;
}
Compiled with gcc version 4.4.6, the program above returns 0 regardless of the
optimization level.
Compiled with gcc versions 4.5.3 or 4.6.1, the return value is 0 only with -O0.
Using -O1, -O2, -O3 or -Os, the return value is 1.
The correct value (0) is returned if s.ptr is replaced with a local variable or
the code from the function f1 is moved inside main.
More information about the Gcc-bugs
mailing list