[cfe-dev] C++ Casting Error Messages
Steve Naroff
snaroff at apple.com
Tue Aug 14 07:06:58 PDT 2007
On Aug 13, 2007, at 9:55 PM, Bill Wendling wrote:
> Hi all,
>
> I was wondering what the wording of the error messages for C++ casts
> should be. Right now, I have them as:
>
> t.cpp:
> int volatile * const * ip;
> float const * const * fpp = reinterpret_cast<float const * const *>
> (ip);
> float const * volatile * fpv = reinterpret_cast<float const *
> volatile *>(ip);
> float const * volatile * const * fpvc = reinterpret_cast<float const
> * volatile * const *>\
> (ip);
>
> $ clang -parse-ast-print t.cpp
> t.cpp:2:29: error: reinterpret_cast from type 'int volatile *const *'
> to type 'float const\
> *const *' casts away constness
> float const * const * fpp = reinterpret_cast<float const * const *>
> (ip);
> ^~~~~~~~~~~~~~~~
> t.cpp:3:32: error: reinterpret_cast from type 'int volatile *const *'
> to type 'float const\
> *volatile *' casts away constness
> float const * volatile * fpv = reinterpret_cast<float const *
> volatile *>(ip);
> ^~~~~~~~~~~~~~~~
> What do you think?
>
Looks pretty good. Here is a diagnostic from the EDG compiler...
"ComeauTest.c", line 2: error: reinterpret_cast cannot cast away
const or other type qualifiers
float const * const * fpp = reinterpret_cast<float const * const *>
(ip);
^
Here is a possible improvement that attempts to combine the best of
both...
t.cpp:2:29: error: reinterpret_cast cannot cast away const or other
type qualifiers from type 'int volatile *const *'
float const * const * fpp = reinterpret_cast<float const * const *>(ip);
^~~~~~~~~~~~~~~~
snaroff
> -bw
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20070814/8133846d/attachment.html>
More information about the cfe-dev
mailing list