This is the mail archive of the gcc@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: RFD: CSiBE failure: typeof sometimes copies toplevel const qualifiers


Richard Guenther wrote:



This has been reported before and the kernel was fixed. typeof now
always "returns" the effective type, including CV qualifiers in effect.


Huh? Why would the effective type of

__typeof__ (*(&uss->p)) x;

be different from

__typeof__ ((uss->p)) x;

?

Moreover, if we include all the CV qualifiers, this example from extend.texi
won't work when x ist const:


@smallexample
#define foo(x)                                                  \
 (@{                                                           \
   typeof (x) tmp;                                             \
   if (__builtin_types_compatible_p (typeof (x), long double)) \
     tmp = foo_long_double (tmp);                              \
   else if (__builtin_types_compatible_p (typeof (x), double)) \
     tmp = foo_double (tmp);                                   \
   else if (__builtin_types_compatible_p (typeof (x), float))  \
     tmp = foo_float (tmp);                                    \
   else                                                        \
     abort ();                                                 \
   tmp;                                                        \
 @})
@end smallexample


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