gcc-11-20240619 is now available

2024-06-19 Thread GCC Administrator via Gcc
Snapshot gcc-11-20240619 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/11-20240619/
and on various mirrors, see https://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 11 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch 
releases/gcc-11 revision db6860bade15af0212e622bbfac8541de084487a

You'll find:

 gcc-11-20240619.tar.xz   Complete GCC

  SHA256=12de51cf87e171b8ffb2ea142fc23ae2d562b286a9aefc42f20cebeac476c77f
  SHA1=324789883ac41e0a724b562f498856314d7382bf

Diffs from 11-20240612 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-11
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.


Re: Union initialization semantics

2024-06-19 Thread Martin Uecker via Gcc
Am Mittwoch, dem 19.06.2024 um 13:59 +0100 schrieb Jonathan Wakely via Gcc:
> On Wed, 19 Jun 2024 at 11:57, Alexander Monakov  wrote:
> > 
> > Hello,
> > 
> > I vaguely remember there was a recent, maybe within last two months, 
> > discussion
> > about semantics of union initialization where sizeof(first member) is less 
> > than
> > sizeof(union). The question was whether it's okay to initialize just that 
> > first
> > member and leave garbage bits in the other, larger, members of the union, 
> > like
> > in this example:
> > 
> > union A {
> > char a;
> > long : 0;
> > };
> > 
> > void fn(void *);
> > 
> > void my(void)
> > {
> > union A a = { 0 };
> > fn(&a);
> > }
> > 
> > (except in my example there's no other named member, but I think the example
> > in that discussion was less contrived)
> > 
> > Perhaps somebody remembers where it was (I'm thinking Bugzilla) and could 
> > point
> > me to it? My attempts to search for it aren't turning anything up so far.
> 
> Somebody asked about this internally at Red Hat recently, and I
> responded with this quote from C17 6.2.6.1 p7:
> "When a value is stored in a member of an object of union type, the
> bytes of the object representation that do not correspond to that
> member but do correspond to other members take unspecified values. "
> 
> This looks related too:
> https://discourse.llvm.org/t/union-initialization-and-aliasing-clang-18-seems-to-miscompile-musl/77724/3
> They don't seem to have found the quote above though.
> 
> I think it got reported to GCC's bugzilla too, I'll see if I can find it 
> again.
> 
> > If someone knows what semantics GCC implements, that also would be welcome.
> 
> GCC seems to initialize the trailing bits, unnecessarily.

Note that C23 will require the padding bits to be initialized with zero
for default initialization {}.

Martin





Re: Union initialization semantics

2024-06-19 Thread Jonathan Wakely via Gcc
On Wed, 19 Jun 2024 at 11:57, Alexander Monakov  wrote:
>
> Hello,
>
> I vaguely remember there was a recent, maybe within last two months, 
> discussion
> about semantics of union initialization where sizeof(first member) is less 
> than
> sizeof(union). The question was whether it's okay to initialize just that 
> first
> member and leave garbage bits in the other, larger, members of the union, like
> in this example:
>
> union A {
> char a;
> long : 0;
> };
>
> void fn(void *);
>
> void my(void)
> {
> union A a = { 0 };
> fn(&a);
> }
>
> (except in my example there's no other named member, but I think the example
> in that discussion was less contrived)
>
> Perhaps somebody remembers where it was (I'm thinking Bugzilla) and could 
> point
> me to it? My attempts to search for it aren't turning anything up so far.

Somebody asked about this internally at Red Hat recently, and I
responded with this quote from C17 6.2.6.1 p7:
"When a value is stored in a member of an object of union type, the
bytes of the object representation that do not correspond to that
member but do correspond to other members take unspecified values. "

This looks related too:
https://discourse.llvm.org/t/union-initialization-and-aliasing-clang-18-seems-to-miscompile-musl/77724/3
They don't seem to have found the quote above though.

I think it got reported to GCC's bugzilla too, I'll see if I can find it again.

> If someone knows what semantics GCC implements, that also would be welcome.

GCC seems to initialize the trailing bits, unnecessarily.


Union initialization semantics

2024-06-19 Thread Alexander Monakov
Hello,

I vaguely remember there was a recent, maybe within last two months, discussion
about semantics of union initialization where sizeof(first member) is less than
sizeof(union). The question was whether it's okay to initialize just that first
member and leave garbage bits in the other, larger, members of the union, like
in this example:

union A {
char a;
long : 0;
};

void fn(void *);

void my(void)
{
union A a = { 0 };
fn(&a);
}

(except in my example there's no other named member, but I think the example
in that discussion was less contrived)

Perhaps somebody remembers where it was (I'm thinking Bugzilla) and could point
me to it? My attempts to search for it aren't turning anything up so far.

If someone knows what semantics GCC implements, that also would be welcome.

Thank you.
Alexander