Article View: comp.std.c++
Article #2552reinterpret_cast<> and discarding const
From: Greg McGary
Date: Mon, 13 Nov 1995 18:08
Date: Mon, 13 Nov 1995 18:08
20 lines
1277 bytes
1277 bytes
C++ Std sez (draft std and all recent WPs) in 5.2.9 (2) `The
reinterpret_cast operator shall not cast away constness.'
Unfortunately, whereas this might be possible to enforce for a single
reinterpret_cast<>, a sequence of two can easily discard
cv-qualifiers:
char const *const *const *const ccpcpcpc;
char *** cppp;
cppp = reinterpret_cast<char ***> (reinterpret_cast<int> (ccpcpcpc))
Nasty.
Does a conforming compiler have any responsibility to detect this hole
(seems doable, but definitely a hassle), or is it just an unfortunate
wart?
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<m0tF2xx-0005hJC@magilla.magilla.cichlid.com>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 13 Nov 95 18:08:17 GMT Approved: fjh@cs.mu.oz.au Organization: - Newsgroups: comp.std.c++ Message-ID: <m0tF2xx-0005hJC@magilla.magilla.cichlid.com> X-Original-Date: Mon, 13 Nov 95 12:46 EST From: Greg McGary <gkm@magilla.cichlid.com> Subject: reinterpret_cast<> and discarding const X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMKeJquEDnX0m9pzZAQGVpAF/ZD9xtOhtgWKKXeAfDiKVF1yMtjHJ8RKj 3kZ8CSj2v+gpS6LmVkZ1DAEk+1UicAqE =WsKj