[Bug c++/51379] reinterpret_cast is not particularly useful

2011-12-01 Thread piotr.wyderski at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51379

--- Comment #1 from Piotr Wyderski piotr.wyderski at gmail dot com 2011-12-01 
12:58:16 UTC ---
Both static_cast and C-type cast work as expected.


[Bug c++/51379] reinterpret_cast is not particularly useful

2011-12-01 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51379

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org 2011-12-01 
13:20:16 UTC ---
This is required by the standard.

[expr.reinterpret.cast] explicitly lists all the conversion allowed by
reinterpret_cast

You'll get the same result from http://llvm.org/demo/ and
http://www.comeaucomputing.com/tryitout/

If GCC, EDG and Clang all reject your code then your code is probably wrong.


[Bug c++/51379] reinterpret_cast is not particularly useful

2011-12-01 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51379

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek jakub at gcc dot gnu.org 2011-12-01 
13:58:29 UTC ---
I wonder about the C++11 wording though, in C++03 it said:
The reinterpret_cast operator shall not cast away constness. [Note: see 5.2.11
for the definition of ‘‘casting away constness’’. Subject to the restrictions
in this section, an expression may be cast to its own type using a
reinterpret_cast operator. ]
but in C++11:
The reinterpret_cast operator shall not cast away constness (5.2.11). An
expression of integral, enumeration, pointer, or pointer-to-member type can be
explicitly converted to its own type; such a cast yields the
value of its operand.
For the latter wording it isn't obvious if the second sentence is subject to
the other restrictions or not.


[Bug c++/51379] reinterpret_cast is not particularly useful

2011-12-01 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51379

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

 Status|RESOLVED|NEW
   Last reconfirmed||2011-12-01
 Resolution|INVALID |
 Ever Confirmed|0   |1

--- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org 2011-12-01 
14:06:47 UTC ---
Ah good point, I didn't realise DR 799 changed that
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#799