This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ and aliasing bools
- From: Daniel Berlin <dan at dberlin dot org>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Joe Buck <jbuck at synopsys dot COM>, Neil Booth <neil at daikokuya dot demon dot co dot uk>, Paolo Carlini <pcarlini at unitus dot it>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 28 Jan 2002 18:41:27 -0500 (EST)
- Subject: Re: g++ and aliasing bools
On Mon, 28 Jan 2002, Mark Mitchell wrote:
>
> [ zero-sized based class example elided ]
>
> >
> > But the C aliasing rules completely ignore the question of size, so you're
> > bringing up a red herring. The rules have *nothing* to do with whether we
> > think that two objects have the same address! It doesn't even come up.
> > For that reason, you don't have to waste any time thinking about class
> > layout.
> >
>
> Joe's argument is a reduction from C++ to C; the claim is that (basically)
> the C++ alias rules are the same as C and that certain C++ classes are
> laid out like certain C structs and that there are no additional
> "dangerous" operations and therefore correctness for C implies correctness
> for C++.
Um, that's Joe talking, i think we are getting attribution messed up.
Unless you really meant to talk about Joe as "Joe's argument", rather than
"His argument".
>
> The argument doesn't work in this case -- the proposed isomorphism from
> C++ classes to C structs is not correct.
>
> Joe's argument either needs to handle zero-sized classes in some other
> way (arguing that they're not dangerous for some other reason), or it
> needs to not apply to class hierarchives that involve zero-sized bases,
> treating such things as not simple_enough.
*I* already argued that they aren't dangerous for another reason. In C,
since they would have the same address, they would alias. In reality,
in C++, they *don't* alias because they *don't* have the same address.
However, it's perfectly fine to say things alias that don't.
Thus, it's not dangerous.
--Dan