https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83654

--- Comment #2 from Florian Weimer <fw at gcc dot gnu.org> ---
I forgot to add a compiler barrier to f2 for the executable test case, so it is
not strictly equivalent.

With it, valgrind reports:

==375147== Invalid read of size 4
==375147==    at 0x8048403: f2 (in /root/build-32/a.out)
==375147==    by 0x80482CA: main (in /root/build-32/a.out)
==375147==  Address 0xfebb3d0c is on thread 1's stack
==375147==  4 bytes below stack pointer

valgrind warns about the final probe.  Here's the disassembly with addresses:

080483e0 <f2>:
 80483e0:       55                      push   %ebp
 80483e1:       89 e5                   mov    %esp,%ebp
 80483e3:       83 ec 08                sub    $0x8,%esp
 80483e6:       8d 84 24 00 f0 ff ff    lea    -0x1000(%esp),%eax
 80483ed:       39 c4                   cmp    %eax,%esp
 80483ef:       74 12                   je     8048403 <f2+0x23>
 80483f1:       81 ec 00 10 00 00       sub    $0x1000,%esp
 80483f7:       83 8c 24 fc 0f 00 00    orl    $0x0,0xffc(%esp)
 80483fe:       00 
 80483ff:       39 c4                   cmp    %eax,%esp
 8048401:       75 ee                   jne    80483f1 <f2+0x11>
 8048403:       83 4c 24 fc 00          orl    $0x0,-0x4(%esp)
 8048408:       83 ec 0c                sub    $0xc,%esp
 804840b:       50                      push   %eax
 804840c:       e8 bf ff ff ff          call   80483d0 <f1>
 8048411:       c9                      leave  
 8048412:       c3                      ret

Reply via email to