[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v2 0/9] qom: Make object_get_class()/*_GET_CLASS r
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [RFC v2 0/9] qom: Make object_get_class()/*_GET_CLASS return const pointers |
Date: |
Mon, 3 Apr 2017 11:44:22 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
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