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 middle-end/48661] New: gcc 4.6 wrong-code regression


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

           Summary: gcc 4.6 wrong-code regression
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: snyder@bnl.gov
              Host: x86_64-unknown-linux-gnu
            Target: x86
             Build: gcc version 4.6.1 20110415 (prerelease) (GCC)


Created attachment 24029
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24029
test case

hi -

gcc 4.6 miscompiles the attached code with -O2.
This was observed in the 4.6.0 release, and also in
4.6.1 20110415 from svn.  I see it both with x86 and x86_64 targets.
I did not see this problem with gcc 4.5.

Example of compiling and running:

$ g++ -m32 -o y -O2 y.cc
$ ./y
123
134514336
$

I expect it to print `123' on the second line as well.

Here's the generated code for testSetters.
Note that an uninitialized value is being passed to the
second printf() call.

    .cfi_startproc
    subl    $44, %esp
    .cfi_def_cfa_offset 48
    leal    28(%esp), %eax
    movl    $_ZTV6P4Impl+12, 20(%esp)
    movl    $_ZTV6P4Impl+36, 28(%esp)
    movl    $123, 24(%esp)
    movl    %eax, (%esp)
    call    _ZTv0_n12_NK6P4Impl2ptEv
    movl    $.LC0, (%esp)
    movl    %eax, 4(%esp)
    call    printf
    movl    32(%esp), %eax  ; this value has not been initialized.
    movl    $.LC0, (%esp)
    movl    %eax, 4(%esp)
    call    printf
    addl    $44, %esp
    .cfi_def_cfa_offset 4
    ret
    .cfi_endproc


Interestingly, the presence of the testGetters() function is required
to trigger the bug, even though it is not called.

Looking at the dumps, a difference seems to show up at the
056t.ehdisp stage.

When the code is being miscompiled, i see this:

  D.2397_35 = MEM[(const struct P4Impl *)&pp + 8B].m_pt;
  D.2396_44 = D.2397_35;
  D.2394_30 = D.2396_44;
  p.m_pt = D.2394_30;
  ...
  D.2297_5 = p.m_pt;
  printf ("%d\n", D.2297_5);


But if i comment out the P4Impl declaration in testGetters(),
i instead see this for testSetters():

  D.2384_34 = MEM[(const struct I4Momentum *)&pp].D.2131._vptr.I4Momentum;
  D.2385_35 = *D.2384_34;
  D.2386_36 = OBJ_TYPE_REF(D.2385_35;&pp.D.2131->0) (&pp.D.2131);

<bb 5>:
  p.m_pt = D.2386_36;
  ...
  D.2267_5 = p.m_pt;
  printf ("%d\n", D.2267_5);

sss


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