www.digitalmars.com         C & C++   DMDScript  

c++ - 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?
Nov 02 2001