RFD: CSiBE failure: typeof sometimes copies toplevel const qualifiers

Joern RENNECKE joern.rennecke@st.com
Thu Jan 5 13:22:00 GMT 2006


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



More information about the Gcc mailing list