[EMAIL PROTECTED] gcc]$ cat x.i
const int conststaticvariable = 3;

int f(void)
{
  return conststaticvariable;
}
[EMAIL PROTECTED] gcc]$ ./xgcc -B./ -O2 x.i -S -fPIC -m32
[EMAIL PROTECTED] 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

Reply via email to