This is the mail archive of the gcc-patches@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: [PATCH] Do not warn about C++ compatibility of casts to incomplete type


On Fri, Oct 29, 2010 at 11:05 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> On 10/29/2010 06:00 PM, Gabriel Dos Reis wrote:
>>
>> On Fri, Oct 29, 2010 at 10:50 AM, Paolo Bonzini<bonzini@gnu.org> ?wrote:
>>>
>>> While working on an unrelated patch I noticed a small imprecision
>>> in -Wc++-compat: casts to pointer to incomplete type are erroneously
>>> flagged as invalid in C++, if the occurrence of the incomplete type
>>> in the cast is also the first one in the translation unit.
>>>
>>> This patch fixes this imprecision. ?Adding a new bit means that
>>> not putting the entire spec.kind into struct c_declspecs is not
>>> cheaper anymore, so this patch does that as well.
>>
>> Hmm, I do not understand the purpose of the warning in the first
>> place. ?I do not think there is any difference between C and C++
>> in this respect, so we should NOT be issueing the warning,
>
> void f(void)
> {
> ? ? ? ?(struct s { int i; } *) 0;
> }
>
> $ gcc f.c -fsyntax-only && echo ok
> ok
> $ g++ f.c -fsyntax-only && echo ok
> f.c: In function ‘void f()’:
> f.c:3: error: types may not be defined in casts

Ah yes, there is a different thing, but I would not describe it as

   casts to pointer to incomplete type are erroneously flagged as
invalid in C++,
   if the occurrence of the incomplete type n the cast is also the first one in
   the translation unit.

:-)

that got me confused.  I believe the same situation is also true for sizeof,
and by extension alignof.

-- Gaby


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