https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65455
pskocik at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pskocik at gmail dot com
--- Comment #22 from pskocik at gmail dot com ---
(In reply to Marek Polacek from comment #18)
> So this looks like a dup of PR39985. It seems that, if anything, we should
> modify __typeof to drop all qualifiers. I.e. that all of the following
> __typeofs yield "int":
>
> const int a;
> volatile int b;
> const volatile c;
> _Atomic int d;
> int *restrict e;
> __typeof (a) x;
> __typeof (b) y;
> __typeof (c) q;
> __typeof (d) r;
> __typeof (const int) z;
> __typeof (volatile const int) w;
> __typeof (volatile int) v;
> __typeof (_Atomic volatile int) t;
> __typeof (*e) *s;
>
> Or is that not so?
>
> What should we do for C++?
As a user, I can always force top-level-qualifier dropping by rvalue conversion
(e.g., with , or ?:) but it(In reply to Jens Gustedt from comment #20)
> I would be much happier with a generic operator that makes any object into
> an rvalue. One way that comes close would be `1 ? (X) : (X)`. This is an
> expression that transforms any expression `X` that is not a narrow integer
> type into an rvalue.
>
> Unfortunately it is too ugly that anybody ever will systematically write
> `__typeof__(1?(X):(X))`. But a macro
>
> #define __typeof_unqual__(X) __typeof__(1?(X):(X))
>
> could do. (And one could fix the finite number of cases that are not covered
> with `_Generic`.)
>
> I'd like to have prefix `+` for that. This could be useful in `__typeof__`
> but also in `_Generic`. Maybe gcc could extend that operator to be
> applicable to all types.
(In reply to Jens Gustedt from comment #20)
> I would be much happier with a generic operator that makes any object into
> an rvalue. One way that comes close would be `1 ? (X) : (X)`. This is an
> expression that transforms any expression `X` that is not a narrow integer
> type into an rvalue.
>
> Unfortunately it is too ugly that anybody ever will systematically write
> `__typeof__(1?(X):(X))`. But a macro
>
> #define __typeof_unqual__(X) __typeof__(1?(X):(X))
>
> could do. (And one could fix the finite number of cases that are not covered
> with `_Generic`.)
>
> I'd like to have prefix `+` for that. This could be useful in `__typeof__`
> but also in `_Generic`. Maybe gcc could extend that operator to be
> applicable to all types.
I agree __typeof should keep all top level qualifs (clang's __typeof does). But
I'd rather the unary + were not extended to non-numeric types. I frequently
rely on it to throw comptime errors when applied to non-numerics. I think the
comma should be able to accomplish the job (__typeof(0,X)) with similar brevity
as that of the unary +.