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]

Re: Apparent aliasing problem when optimizing


Marc Singer <elf at buici dot com> writes:

> 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.

Change

    HRESULT result =
      m_psfDesktop->BindToObject (pidl, __null, IID_IShellFolder, &(void*)psf);

to

    HRESULT result =
      m_psfDesktop->BindToObject (pidl, __null, IID_IShellFolder, (PVOID*)&psf);

and it should start working correctly.  (Your code should get a
warning, or perhaps even a hard error - you're applying the & operator
to a cast to non-reference type, which is not an lvalue, so it's
invalid.)

I see several other places where the code contains the same mistake.

zw


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