Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260311114135.GM3520958@port70.net>
Date: Wed, 11 Mar 2026 12:41:35 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: Rich Felker <dalias@...c.org>
Cc: Thorsten Glaser <tg@...bsd.de>, musl@...ts.openwall.com
Subject: Re: Question about flexible array

* Rich Felker <dalias@...c.org> [2026-03-11 00:01:25 -0400]:
> On Mon, Aug 11, 2025 at 10:42:29AM -0400, Rich Felker wrote:
> > On Mon, Jun 17, 2024 at 04:29:35AM +0000, Thorsten Glaser wrote:
> > > 樊鹏 dixit:
> > > 
> > > >The reason is a difference between gcc and g++:
> > > >
> > > >Flexible array members are not officially part of C++.
> > > >Flexible array members were officially standardized in C99.
> > > 
> > > >/usr/include/bits/signal.h:35:23: error: flexible array member 'mcontext_t::__extcontext' not at end of 'struct tbb::detail::r1::coroutine_type'
...
> Is this something that needs to be fixed? I don't recall where but I
> think it was raised somewhere else, that there doesn't seem to be
> anywhere to store the call-saved fpu registers when implementing the
> ucontext functions...

the difference between glibc and musl is
struct {int x[0];} vs struct {int x[];}

technically the y,z ordering is wrong here in c99:
struct {struct {int x[];} y; int z;}
x[0] works but it is a gnu extension so wrong in c99.

in practice x[0] works with the wrong order:
gcc -xc: x[0] ok, x[] ok
gcc -xc++: x[0] ok, x[] error
clang -xc: x[0] ok, x[] warn
clang -xc++: x[0] ok, x[] warn
https://godbolt.org/z/8YY8EYdEb

gcc -pedantic warns about the order and the x[0] extension.

i guess the fix is to do x[0] like glibc, should be only
a c++ api change, not abi. not iso c but unlikely to
cause trouble (i would not do ifdef c++).

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.