g++ and aliasing bools
Mark Mitchell
mark@codesourcery.com
Mon Jan 28 15:59:00 GMT 2002
[ 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
More information about the Gcc
mailing list