This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][4.8] C++ memory model bitfield handling rewrite
- From: Richard Guenther <rguenther at suse dot de>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 7 Feb 2012 15:00:11 +0100 (CET)
- Subject: Re: [PATCH][4.8] C++ memory model bitfield handling rewrite
- References: <CAH6eHdSQxxoC7cgfrU=kaxZ+HP2SqTqKVuVfAkWcLvGkpjGJRw@mail.gmail.com>
On Tue, 7 Feb 2012, Jonathan Wakely wrote:
> Hi Richard,
>
> re http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00280.html (I'm not
> subscribed to gcc-patches so only read it in the archive)
>
> > Note that in the above case
> > tail-padding is _not_ reused (for some reason).
>
> Tail-padding in PODs can't be reused according to the ABI. Give Base
> a user-defined constructor or destructor and it gets reused.
Ah, thanks. Thus, for the following testcase
struct Base {
Base();
int i : 1;
};
struct Deriv : Base {
char d : 2;
char x;
};
Deriv s;
void foo ()
{
s.i = 1;
s.d = 2;
s.x = 3;
}
What does the C++ memory model say about accesses to s.i, s.d and s.x?
What would it have said for -fabi-version=1 where for
we place s.i and s.d into the same byte?
Thanks,
Richard.