[cfe-dev] Question about Casting Away Constness

Steve Naroff snaroff at apple.com
Fri Aug 3 06:55:19 PDT 2007


Bill,

I don't fully understand your email/question.

It would help me if you referenced the standard directly. For  
example, which clause 4?

snaroff

On Aug 2, 2007, at 11:43 PM, Bill Wendling wrote:

> Hi all,
>
> I have a question about implementation of performing a casting away
> constness check. Here's an example representing the wording in the
> standard. If Tn and Xn represent types, then for two pointer types:
>
>     X1 is T1 cv1,1 * cv1,2 * cv1,3 * cv1,N=4 *
>     X2 is T2 cv2,1 * cv2,2 * cv2,3 * cv2,4 * cv2,5 * cv2,6 * cv2,M=7 *
>
>     K = min(N,M);
>
> casting from X1 to X2 casts away constness if for a non-pointer type
> T there does not exist an implicit conversion (clause 4) from:
>
> (1)   T cv1,1 * cv1,2 * cv1,3 * cv1,4 *
>
> to
>
> (2)   T cv2,4 * cv2,5 * cv2,6 * cv2,7 *
>
> How would you suggest going about this? I was thinking of looping
> through the pointees of the pointers to try to come up with (1) and
> (2) in this example. Is this feasible? After we get that, is there a
> way to "fake" a type (the 'T' in this example) so that we can do the
> implicit conversion check? And, lastly, is there already a check for
> implicit conversions?
>
> Sorry that this is kind of a lot, and that some of it is basic. I
> just don't want to waste a lot of time. :-)
>
> Thanks!
> -bw
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list