November 02, 2001 casting away constness with reinterpret_cast | ||||
---|---|---|---|---|
| ||||
According to the C++ standard, "the reinterpret_cast operator shall not cast away constness." (5.2.10 Reinterpret cast, paragraph 2)
But DM doesn't complain about it:
int main(int argc, char *argv[])
{
const int a = -1;
char *b = reinterpret_cast<char *>(&a);
return *b;
}
bye, Christof
--
http://cmeerw.cjb.net JID: cmeerw@jabber.at mailto cmeerw at web.de
...and what have you contributed to the Net?
|
Copyright © 1999-2021 by the D Language Foundation