This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ and aliasing bools
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Joe Buck <jbuck at synopsys dot COM>, Daniel Berlin <dan at dberlin dot org>
- Cc: 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 15:18:44 -0800
- Subject: Re: g++ and aliasing bools
- References: <200201281722.JAA08937@atrus.synopsys.com>
[ 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++.
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.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com