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/35501] New: Wrong value returned from const int


[hjl@gnu-26 gcc]$ cat x.i
const int conststaticvariable = 3;

int f(void)
{
  return conststaticvariable;
}
[hjl@gnu-26 gcc]$ ./xgcc -B./ -O2 x.i -S -fPIC -m32
[hjl@gnu-26 gcc]$ cat x.s
        .file   "x.i"
        .text
        .p2align 4,,15
.globl f
        .type   f, @function
f:
        pushl   %ebp
        movl    $3, %eax
        movl    %esp, %ebp
        popl    %ebp
        ret

We can't return 3 when PIC is used since conststaticvariable may
be resolved to another definition at run-time.


-- 
           Summary: Wrong value returned from const int
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl dot tools at gmail dot com


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


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