Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260311162543.GG1827@brightrain.aerifal.cx>
Date: Wed, 11 Mar 2026 12:25:43 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Question about flexible array

On Wed, Mar 11, 2026 at 12:41:35PM +0100, Szabolcs Nagy wrote:
> * 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++).

That's not what I'm worried about. Rather I'm worried about the fact
that, if you make an object of type ucontext_t with size
sizeof(ucontext_t), there's nowhere for the floating point registers
to be stored despite them being call-saved per the ABI. AFAICT this
makes libucontext impossible to implement correctly.

Rich

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.