[cfe-dev] clang rejects nested struct-member-access-typeof

Jan Engelhardt jengelh at medozas.de
Wed Nov 2 06:01:01 PDT 2011


On Wednesday 2011-11-02 04:51, Douglas Gregor wrote:
>> 	void *p = 0;
>> 	typeof((struct { typeof((struct { void *m; }){p}.m) n; }){0}.n) q = 0;
>
>This code is relying on GCC extensions to treat a compound literal
>as a constant expression, which C99 forbids.

I do not think this should have anything to do with constexprs, also
because typeof does not really evaluate its argument, but just looks
at the type system. Clang accepts a handful of - what looks to me
like non-constant expressions - to typeof:

	typeof((struct { void *m; }){p}.m) q = 0;

	typeof(argc) argc2 = argc;

>Feel free to file a bug; this might be the kind of thing that we can
>support for GNU compatibility, if it falls out of the constexpr and
>other C++11 work in this area.

I guess I did by writing to this list.



More information about the cfe-dev mailing list