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:

> On Wed, Apr 09, 2003 at 10:50:59PM -0700, Zack Weinberg wrote:
>> 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.
>
> When compiling with -Wall there are no warning.

Sorry, that was too elliptical.  I wanted to say, not that GCC does
now issue a warning for your code, but that it should be made to issue
a warning, or perhaps even an error.

> I read your explanation.  Why (void*) cannot be a reference type
> when (IShellFolder*) is?

Neither of them is a reference type.  You can take the address of a
*variable* of any type, but you cannot take the address of a *cast*.

zw


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