This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++ and aliasing bools



[ 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]