On 02/04/2017 15:31, Eduardo Habkost wrote:
> When trying to change OBJECT and OBJECT_CHECK, I've found a
> problem: gcc 6.2.1 can't evaluate typeof(*a) if *a has an
> incomplete type, even inside the (const typeof(*(t)0) *)
> expression used in QUALIFIED_CAST. It works on clang, though.
> 
> I'm not sure we want to introduce something that would report
> errors only on clang only[1]. Especially when the error messages
> look like this:
>   hw/mem/pc-dimm.c:248:23: error: passing 'typeof (_Generic((const typeof 
> (*((typeof ((a)))0)) *)0, typeof ((a)): (const Object *)(0), default: (Object 
> *)(0)))' (aka 'const struct Object *') to parameter of type 'Object *' (aka 
> 'struct Object *') discards qualifiers 
> [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
>       PCDIMMDevice *x = PC_DIMM(a);
> 
> Lucikly all the OBJECT_CLASS usage I've found never involved
> incomplete types, but they are more common when dealing with
> object pointers.
> 
> We could also require all users of OBJECT(x) to include the
> header that defines the struct type of x. But I'm not sure it's
> worth the effort.

Fair enough!  Thanks for trying.

Paolo

Reply via email to