[cfe-dev] C++ status report web page

Bill Wendling isanbard at gmail.com
Wed Jul 2 09:26:42 PDT 2008


More situations it doesn't emit errors for:

typedef double *dptr;
typedef const double *cdptr;

void reinterpret_cast_check() {
   short s;
   double *d;
   float *f;
   const double * const ccd;     // FIXME: Should error about  
uninitialized const.
   const double *cd;
   int const * volatile * vci;
   double * const * volatile * *vcd;

   dptr t_d;
   cdptr t_cd;

   // No errors:
   t_d = reinterpret_cast<dptr>(d);
   f = reinterpret_cast<float*>(d);
   cd = reinterpret_cast<const double *>(ccd);

   // Expected errors:
   f = reinterpret_cast<float*>(cd); // expected-error  
{{reinterpret_cast cannot cast \
away const}}
   s = reinterpret_cast<short>(f);   // expected-error {{loss of  
precision}}
   vcd = reinterpret_cast<double*const*volatile**>(vci); // expected- 
error {{reinterpr\
et_cast cannot cast away const}}
   t_d = reinterpret_cast<dptr>(t_cd); // expected-error  
{{reinterpret_cast cannot cas\
t away const}}
}


Enjoy!
-bw



More information about the cfe-dev mailing list