This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Apparent aliasing problem when optimizing
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Marc Singer <elf at buici dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 09 Apr 2003 22:50:59 -0700
- Subject: Re: Apparent aliasing problem when optimizing
- References: <20030410043736.GA11335@buici.com>
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