[cfe-dev] Question about Casting Away Constness
Bill Wendling
isanbard at gmail.com
Thu Aug 2 23:43:30 PDT 2007
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
More information about the cfe-dev
mailing list