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]

Apparent aliasing problem when optimizing


[The gcc.gnu.org site stopped responding while I composed this message
  in GNATS.  Here it is by mail.]

I've found this problem in 

  g++-3.2 (GCC) 3.2.3 20030331 (Debian prerelease)

though I am building this application with this cross compiler

  i586-mingw32msvc-g++ (GCC) 3.2.1 (MinGW special 20021202-2) 

The function SendTo::sendto_folder() fails when the file is compiled
with -Os optimization.  The trouble is that the function *always*
returns NULL when optimized.  It's OK when -O0 optimization is
applied.  I've included the the assembler output as a comment near the
function.  It looks like the compiler only sees the initialization of
psf with NULL and no explicit change.  However, the BindToObject call
will update psf if it succeeds.

I spent some time reducing this example to a program that would run.
With previous cases of this type of error it was easy to create a
small example.  In this one, however, it is less so.  It may have to
do with the presence of the jump table dereference as that was never
in my sample.  None of my samples could reproduce the errant behavior.

When compiled with -Os, the attached .i file produces the same
erroneous exit sequence with xor eax, eax at label .L139.

  g++-3.2 -c -g -Wall -Os -Wa,-alh=sendto_3.2.3.cod,-L -c -o /dev/null sendto.i

It is possible to work around the bug by passing a temporary void*
address to BindToObject and then storing that result back into psf.

Let me know if you need for information.

Cheers,
  Marc Singer

Attachment: sendto.i.gz
Description: Binary data


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