This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Possible bug in gcc 4.4.7
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "Andy Falanga (afalanga)" <afalanga at micron dot com>
- Cc: Andrew Haley <aph at redhat dot com>, "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 18 Sep 2014 01:12:31 +0100
- Subject: Re: Possible bug in gcc 4.4.7
- Authentication-results: sourceware.org; auth=none
- References: <60F6FAE47D1BCE4380CC06D18F49789B93F81C6E at NTXBOIMBX02 dot micron dot com> <CAH6eHdT4O3kwTwE-bhQ56uWwyZC_K7wcSnJkKzVcuXM+W3Mneg at mail dot gmail dot com> <60F6FAE47D1BCE4380CC06D18F49789B93F81CD4 at NTXBOIMBX02 dot micron dot com> <5419CD78 dot 9040703 at redhat dot com> <60F6FAE47D1BCE4380CC06D18F49789B93F81D6D at NTXBOIMBX02 dot micron dot com>
On 17 September 2014 21:34, Andy Falanga (afalanga) wrote:
> Thank you for the reference. I'm going to have to think on this for a bit. I read a bit of the definition for reinterpret_cast in the C++ Draft I have too. I want to figure this out for sure.
I think you're barking up the wrong tree if you're trying to
understand when reinterpret_cast is suitable ... because it is almost
never a good idea! reinterpret_cast basically means "just shut up and
do this cast, I know what I'm doing", but that means you've lost the
advantages of having the compiler do type checking.
The rules Andrew quoted say when it's OK to violate the language's
type system. If you try to break those rules you can use
reinterpret_cast to make the compiler shut up and do what it's told,
but you're still breaking the rules.