public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <une+c@alejandro-colomar.es>
To: Robert Seacord <rcseacord@gmail.com>
Cc: "sc22wg14@open-std. org" <sc22wg14@open-std.org>,
	 Florian Weimer <fweimer@redhat.com>,
	Carlos O'Donell <carlos@redhat.com>,
	 Aaron Ballman <aaron@aaronballman.com>,
	libc-alpha@sourceware.org, musl@lists.openwall.com,
	 linux-man@vger.kernel.org
Subject: Re: n3752, alx-0029r8 - Restore the traditional realloc(3) specification
Date: Wed, 7 Jan 2026 00:08:37 +0100	[thread overview]
Message-ID: <aV2SUysaLtL2MJWf@devuan> (raw)
In-Reply-To: <20260106214930.A5C8E356D2B@www.open-std.org>

[-- Attachment #1: Type: text/plain, Size: 4531 bytes --]

Hi Robert,

On Tue, Jan 06, 2026 at 04:49:18PM -0500, Robert Seacord wrote:
> It's sort of unusual for the committee to pass some sort of statement
> saying we won't change the behavior of something.  Besides your paper,  I
> don't know of any proposals that would affect realloc. Maybe we should hear
> from the UB Study Group as maybe they have some idea to eliminate this UB.

Here are my plans for the next meeting:

A)  Vote the proposal in its entirety.  Ideally, this would pass, which
    would align us with POSIX.

B)  If that doesn't pass, vote the first step (see 'Design decisions'),
    which would be to make realloc(p,s) consistent with free(p) and
    malloc(s), including when p==NULL, and including when size==0.  This
    would be a narrower change that would only affect MS and glibc (and
    compatible implementations).

C)  If that doesn't pass, vote a statement that the committee agrees
    to not remove the UB unless it's for aligning with the traditional
    BSD behavior.

> 
> I think my preference (and I think the consensus of WG14 in Brno) is to
> provide a replacement function with well-defined behavior and deprecate the
> existing function.

Again, this is dead on arrival.

-  The BSDs and musl have a perfect realloc(3), and they won't change
   it.  Programs work well with their realloc(3), so what incentive
   would they have to change the world?

-  POSIX has also already agreed to fix realloc(3), so the above extends
   to all POSIX systems: once realloc(3) is fixed in their systems, what
   would be the incentive to use a new realloc variant that works in the
   same exact way?

Also, the consensus reached in Brno is flawed, as several members told
me they'd change their vote just a few hours later.  They admitted not
having read the proposal prior to the vote, and that after when they
understood the proposal, they agreed with it.

Plus, it was just a non-binding direction poll, so the interpretation is
up to me, and I consider the direction is now to insist, per the quick
change of mind of several committee members, and the recent POSIX
agreement.


Have a lovely night!
Alex

> 
> Thanks,
> rCs
> 
> On Tue, Jan 6, 2026, 4:05 PM Alejandro Colomar <une+c@alejandro-colomar.es>
> wrote:
> 
> > Hi Robert,
> >
> > On Tue, Jan 06, 2026 at 03:12:36PM -0500, Robert Seacord wrote:
> > > I'm still waiting to hear from GCC that they plan to change the behavior
> > of
> > > realloc and break their existing code.
> >
> > realloc(3) is part of glibc, not GCC.
> >
> > From glibc, I can quote Florian Weimer:
> >
> > <
> > https://inbox.sourceware.org/libc-alpha/8734kl1pim.fsf@oldenburg.str.redhat.com/
> > >
> >
> > | I'm open to looking at this again once the C standard fully specifies
> > | the behavior of zero-sized objects, the return value of malloc (0), and
> > | so on.  Getting aligned behavior between implementations on these
> > | fundamental interfaces seems quite valuable to programmers.  But
> > | addressing one zero-object-size case and leaving all the others as
> > | unclear as before doesn't seem to be useful, especially given that a
> > | ffuture standard may require different behavior anyway.  A
> > | piece-by-piece transition to the newly required behaviors is also more
> > | onerous on programmers than one well-defined transition in a single
> > | glibc release.
> >
> > He's CCd, in case he wants to comment further.
> >
> > >  If GCC plans to do this, it could
> > > well change my vote.
> > > Better still, they should just change it now.
> >
> > I agree with you.  But they are worried that the committee might later
> > "require different behavior anyway".  That's why a statement from the
> > committee saying "we agree to not change this UB to something different
> > than the traditional behavior" would be useful.
> >
> > >  It's currently UB so they
> > > can make your proposed changes without breaking compatibility with the
> > > standard.
> >
> > They worry about compatibility to future standards, which is reasonable
> > given how volatile the C Committee has been historically regarding these
> > APIs.
> >
> > > FWIW, the reason we got here is because we didn't want to force compilers
> > > to break their existing code to remain compliant.
> > >
> > > Thanks,
> > > rCs
> >
> > Have a lovely night!
> > Alex
> >
> > --
> > <https://www.alejandro-colomar.es>
> >

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

       reply	other threads:[~2026-01-06 23:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251223161139.196AB356CF9@www.open-std.org>
     [not found] ` <20251223164349.F0BC5356D1A@www.open-std.org>
     [not found]   ` <CACqWKsOkbArXm0XBUHkLcFFwDUP8iDQv_xPeNbomR0bKf-GCFw@mail.gmail.com>
     [not found]     ` <20251223211529.6365A356CF9@www.open-std.org>
     [not found]       ` <CACqWKsNQCchFZnFKKAyi-3HDtJYQ6sc=UZeb+hX48WQ1e7yj_w@mail.gmail.com>
     [not found]         ` <20260106210527.AA3FA356D3A@www.open-std.org>
     [not found]           ` <20260106214930.A5C8E356D2B@www.open-std.org>
2026-01-06 23:08             ` Alejandro Colomar [this message]
     [not found]             ` <PH1P110MB1636A1DEC402A702C28EBA9ECC84A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM>
2026-01-07  7:51               ` [SC22WG14.34664] n3752, alx-0029r8 - Restore the traditional realloc(3) specification Alejandro Colomar
     [not found]                 ` <PH1P110MB1636D74EDD4F3074AC98F12FCC84A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM>
     [not found]                   ` <PH1P110MB163601133BF0167C46C8CC9DCC84A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM>
2026-01-07 17:30                     ` Florian Weimer
2026-01-07 20:28                       ` Alejandro Colomar
2026-01-08 11:18                         ` Florian Weimer
2026-01-08 11:53                           ` [musl] " Adhemerval Zanella Netto
2026-01-07 20:36                     ` [SC22WG14.34672] " Alejandro Colomar
     [not found]                     ` <20260108023757.3C908356D01@www.open-std.org>
2026-01-08 11:08                       ` [SC22WG14.34681] " Alejandro Colomar
2026-01-07 20:16                   ` [SC22WG14.34664] " Alejandro Colomar
2026-01-07 22:01                     ` Joseph Myers
     [not found]                     ` <20260107220138.AE8DF356CFB@www.open-std.org>
2026-01-08 14:59                       ` [SC22WG14.34679] " Martin Uecker
     [not found]                         ` <PH1P110MB16361EF635C579E30308D647CC85A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM>
2026-01-08 16:26                           ` Joseph Myers
     [not found]           ` <20260106221652.F02B3356D1A@www.open-std.org>
2026-01-06 23:15             ` [SC22WG14.34665] " Alejandro Colomar
     [not found]       ` <20260106201250.2A0A5356CEC@www.open-std.org>
     [not found]         ` <4dda2463-3adf-4fdf-a2c9-d58a2cdce415@informatik.uni-frankfurt.de>
2026-01-07 20:00           ` [SC22WG14.34662] " Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aV2SUysaLtL2MJWf@devuan \
    --to=une+c@alejandro-colomar.es \
    --cc=aaron@aaronballman.com \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=musl@lists.openwall.com \
    --cc=rcseacord@gmail.com \
    --cc=sc22wg14@open-std.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox