This is the mail archive of the gcc-bugs@gcc.gnu.org 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 tree-optimization/49873] New: Optimizer regression


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.


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