Skip to contentSkip to conversation

n3752, alx-0029r8 - Restore the traditional realloc(3) specification

DISCUSSION Alejandro Colomar 5 participants 14 messages Jan 6 – Jan 8 16 messages not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CACqWKsOkbArXm0XBUHkLcFFwDUP8iDQv_xPeNbomR0bKf-GCFw@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CACqWKsNQCchFZnFKKAyi-3HDtJYQ6sc=UZeb+hX48WQ1e7yj_w@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Hi Robert,

Quoted 4 lines · Robert Seacord

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.

Quoted 4 lines

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

Quoted 64 lines

Thanks,
rCs

Quoted 57 lines · Alejandro Colomar

Hi Robert,

Quoted 1 line · Robert Seacord

I'm still waiting to hear from GCC that they plan to change the behavior

of

Quoted 1 line

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/[email protected]/

Quoted 1 line
| 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.

Quoted 3 lines

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.

Quoted 3 lines

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.

Quoted 5 lines

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>

Signature · 1 line
<https://www.alejandro-colomar.es>

A message that is not in the archive (sent off-list or not yet received): PH1P110MB1636A1DEC402A702C28EBA9ECC84A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM

#9 lore raw

Hi David,

On Wed, Jan 07, 2026 at 12:47:18AM +0000, David Svoboda wrote:
[...]

Quoted 3 lines

I could argue that this UB is really redundant, as it is a variant of the UB you get from reading past the end of an array. (notwithstanding that the array has zero length).

Clearly not. First of all, requesting an array of zero elements is not accessing the array, so you can't put both UB in the same category.

Second, NULL is not an array of zero elements. NULL is an invalid pointer. You can't do anything with NULL (or you couldn't until it was changed recently). With an array of zero elements, you can do pointer arithmetic and hold the pointer just fine, as long as you don't read past the end:

	int     a[0];
	int     *p, *end;

	p = a;
	end = a + _Countof(a);

	while (p < end)
		do_stuff(p);

The above is valid in compilers that support arrays of zero elements, but is (was) not valid with NULL.

And third, a pointer to the first element of an array of zero elements is *not* past the end; it is the same as a pointer one after the last element, and thus it's perfectly valid to hold it.

Quoted 2 lines

We could also argue that this should be implementation-defined behavior, or even unspecified behavior.

No, this is what we had in C17, and UB is much better than that. C17 destroyed the standard definition of realloc(p,0), even though it was supposed to be a no-op change. To some degree, I'm happy that that changed, as that brought us to now, where it is obvious that the only way forward is to go back to the traditional BSD specification.

Quoted 4 lines

However, the UBSG's current
arsenal for slaying earthly demons has traditionally not extended to changing what platforms do, as n3752 does. So IMO the UBSG should stand back and wait for n3752 to be resolved.

Have a lovely day!
Alex

Signature · 1 line
<https://www.alejandro-colomar.es>

A message that is not in the archive (sent off-list or not yet received): PH1P110MB1636D74EDD4F3074AC98F12FCC84A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM

A message that is not in the archive (sent off-list or not yet received): PH1P110MB163601133BF0167C46C8CC9DCC84A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM

#12 lore raw

* David Svoboda:

Quoted 10 lines

WRT this text:

Code written for platforms returning a null pointer can be
      migrated to platforms returning non-null, without significant issues.

I am very skeptical that this is indeed true. But to be precise, this is Glibc's problem rather than WG14's. If they are willing to change glibc to return non-null on realloc(0), then I am willing to agree to this change in ISO C.

If glibc makes the change, it becomes the problem of our users (and developers who interpose glibc's malloc). I'm not sure that's a helpful approach. Someone needs to take responsibility.

For glibc, we would have to do some analysis to figure out the impact. I don't think the glibc team at Red Hat will be able to work on this in the foreseeable future. I don't we should make such changes upstream without such an analysis.

What's Microsoft's position on this entire topic? I thought they use the glibc behavior, too?

Thanks,
Florian

#13 lore raw

Hi Florian, David,

Quoted 12 lines · Florian Weimer

* David Svoboda:

Quoted 10 lines

WRT this text:

Code written for platforms returning a null pointer can be
      migrated to platforms returning non-null, without significant issues.

I am very skeptical that this is indeed true. But to be precise, this is Glibc's problem rather than WG14's. If they are willing to change glibc to return non-null on realloc(0), then I am willing to agree to this change in ISO C.

A major implementation, gnulib, has done the switch in 2024 after this proposal. No regressions are known. We would have certainly noticed if something important had happened.

Quoted 3 lines

If glibc makes the change, it becomes the problem of our users (and developers who interpose glibc's malloc). I'm not sure that's a helpful approach.

A reminder: glibc's realloc(p,0) already can return non-null (if p==NULL before the call). This means that correct glibc code must be able to handle the possibility of realloc(p,0) returning a non-null pointer.

Quoted 1 line

Someone needs to take responsibility.

What do you mean exactly by this?

Quoted 1 line

For glibc, we would have to do some analysis to figure out the impact.

I have done some theoretical analysis in the paper.

gnulib has done some experimental analysis, to the extent that it has done the change in 2024, and we're already in 2026 and we've seen zero regression reports so far. This is used in GNU coreutils, which is certainly something essential enough that if it had any important issues, we would have noticed by now.

You could do some more, but with the resources we have, this should be quite convincing.

Quoted 6 lines

I don't think the glibc team at Red Hat will be able to work on this in the foreseeable future. I don't we should make such changes upstream without such an analysis.

What's Microsoft's position on this entire topic? I thought they use the glibc behavior, too?

Microsoft doesn't seem to have representation in the committee. At least, they haven't showed up to talk about this.

Cheers,
Alex

Quoted 4 lines

Thanks,
Florian

Signature · 1 line
<https://www.alejandro-colomar.es>
#14 lore raw

* Alejandro Colomar:

Quoted 11 lines

Hi Florian, David,

Quoted 8 lines · Florian Weimer

* David Svoboda:

Quoted 6 lines

WRT this text:

Code written for platforms returning a null pointer can be
      migrated to platforms returning non-null, without significant issues.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

I am very skeptical that this is indeed true. But to be precise, this is Glibc's problem rather than WG14's. If they are willing to change glibc to return non-null on realloc(0), then I am willing to agree to this change in ISO C.

A major implementation, gnulib, has done the switch in 2024 after this proposal. No regressions are known. We would have certainly noticed if something important had happened.

gnulib is a sub-settable copylib, so it only affects gnulib-using applications that end up copying the relevant realloc implementation from gnulib (there are at least two). This is a relatively small set of applications, and they typically run only for a limited time.

It's not that users update systems to a newer gnulib and applications switch to a different realloc implementation. It's a very incremental roll-out.

Quoted 3 lines
Quoted 1 line

Someone needs to take responsibility.

What do you mean exactly by this?

It was suggested that WG14 can just make the change and ignore its consequences for glibc and other implementations. For glibc, we could also make the change and tell our users to deal with the breakage. I don't think this is a good approach.

Quoted 2 lines

You could do some more, but with the resources we have, this should be quite convincing.

I don't feel comfortable changing glibc based on the data we have so far.

Thanks,
Florian

#15 lore raw
Quoted 40 lines · Florian Weimer

* Alejandro Colomar:

Quoted 11 lines

Hi Florian, David,

Quoted 8 lines · Florian Weimer

* David Svoboda:

Quoted 6 lines

WRT this text:

Code written for platforms returning a null pointer can be
      migrated to platforms returning non-null, without significant issues.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

I am very skeptical that this is indeed true. But to be precise, this is Glibc's problem rather than WG14's. If they are willing to change glibc to return non-null on realloc(0), then I am willing to agree to this change in ISO C.

A major implementation, gnulib, has done the switch in 2024 after this proposal. No regressions are known. We would have certainly noticed if something important had happened.

gnulib is a sub-settable copylib, so it only affects gnulib-using applications that end up copying the relevant realloc implementation from gnulib (there are at least two). This is a relatively small set of applications, and they typically run only for a limited time.

It's not that users update systems to a newer gnulib and applications switch to a different realloc implementation. It's a very incremental roll-out.

Quoted 3 lines
Quoted 1 line

Someone needs to take responsibility.

What do you mean exactly by this?

It was suggested that WG14 can just make the change and ignore its consequences for glibc and other implementations. For glibc, we could also make the change and tell our users to deal with the breakage. I don't think this is a good approach.

Quoted 5 lines
Quoted 2 lines

You could do some more, but with the resources we have, this should be quite convincing.

I don't feel comfortable changing glibc based on the data we have so far.

I tend to agree, we may try to change using compat symbols but it would add extra complications on malloc interposes.

#16 lore raw
In reply to a message not in the archive

Hi David,

Quoted 4 lines · David Svoboda

Here are some more thoughts on n3752

I wish the paper said something in the intro along the lines of "the goal to change realloc(0) to return a non-null value upon success".

Agree; that could be said more explicitly. If I need to write another revision, I'll try to remember to include that.

Quoted 4 lines

That is implicit in the paper, but should be explicit.

Alex, I recommend that when presenting this paper, please explain carefully the edge cases of how realloc() currently works in C23.

In C23, it doesn't work at all; that's the point. :-)

Quoted 4 lines

This is because some of us know how it works in C17, some of us remember DR 400,
some only know C99's behavior,
and some only know C89's.

The wording in all those standards is so inconsistent, that I doubt there's a unique interpretation, and thus I doubt most people know how it worked in those standards.

I think the only appropriate description of realloc(p,0) is that it was never correctly specified in the standard, and what matters is what implementations did in the real world.

Quoted 2 lines

So your audience is fragmented, and think they know how it works (without knowing the edge cases like realloc(0)).

They should really read the paper.

Quoted 7 lines

WRT this text:

Code written for platforms returning a null pointer can be
      migrated to platforms returning non-null, without significant issues.

I am very skeptical that this is indeed true.

gnulib has done the change in 2024. No regressions have been reported. It is a major implementation, used in Linux systems by essential programs, and in POSIX systems also by many programs.

Quoted 6 lines

But to be precise, this is Glibc's problem rather than WG14's. If they are willing to change glibc to return non-null on realloc(0), then I am willing to agree to this change in ISO C.

Is there any evidence that changing this behavior breaks no code? Any test failures? Any surveys?

There is gnulib having changed its behavior after this paper. No problems have been reported.

Quoted 3 lines

This paper ignores Windows other than to mention that it would need to change too. I doubt MS will update MSVC to accommodate this paper. So accepting this paper makes MSVC noncompliant.

I have no ways of contacting MS. If anyone knows MS people from WG21 that would be relevant, please bring them into the discussion.

Cheers,
Alex

Quoted 105 lines

--

David Svoboda [email protected]<mailto:[email protected]>

Senior Software Security Engineer

CERT Applied Systems Group

(412) 596-0401

From: David Svoboda <[email protected]>
Date: Wednesday, January 7, 2026 at 8:38 AM
To: Alejandro Colomar <[email protected]>
Cc: Robert Seacord <[email protected]>, sc22wg14@open-std. org <[email protected]>, Florian Weimer <[email protected]>, Carlos O'Donell <[email protected]>, Aaron Ballman <[email protected]>, [email protected] <[email protected]>, [email protected] <[email protected]>, [email protected] <[email protected]>, David Svoboda <[email protected]>
Subject: Re: [SC22WG14.34664] n3752, alx-0029r8 - Restore the traditional realloc(3) specification

Hi, Alex!

I'm just going to respond to your first point (about what precisely the UB is):

The n3605 Annex J text says:

(157) A non-null pointer returned by a call to the calloc, malloc, realloc, or aligned_alloc function with a zero requested size is used to access an object (7.25.4).

This suggests that working with a non-null pointer that has been returned from realloc() is the UB, not invoking realloc(0).

But 7.25.4.8 (realloc) text says:

Otherwise, if ptr does not match a pointer earlier returned by a memory management function, or if the space has been deallocated by a call to the free or realloc function, or if the size is zero, the behavior is undefined.

So you're right...UB comes from actually invoking realloc(), not working with whatever it returned. The Annex J wording needs some cleanup. Unless your paper gets accepted, in which case this Annex J UB goes away (and it wouldn't hurt to mention this in your paper, as we have found lots of obsolete UBs in Annex J).

On 1/7/26, 3:43 AM, "Alejandro Colomar" <[email protected]> wrote:

Hi David,

On Wed, Jan 07, 2026 at 12:47:18AM +0000, David Svoboda wrote:
[...]

Quoted 3 lines

I could argue that this UB is really redundant, as it is a variant of the UB you get from reading past the end of an array. (notwithstanding that the array has zero length).

Clearly not. First of all, requesting an array of zero elements is not accessing the array, so you can't put both UB in the same category.

Second, NULL is not an array of zero elements. NULL is an invalid pointer. You can't do anything with NULL (or you couldn't until it was changed recently). With an array of zero elements, you can do pointer arithmetic and hold the pointer just fine, as long as you don't read past the end:

int a[0];
int *p, *end;

p = a;
end = a + _Countof(a);

while (p < end)
do_stuff(p);

The above is valid in compilers that support arrays of zero elements, but is (was) not valid with NULL.

And third, a pointer to the first element of an array of zero elements is *not* past the end; it is the same as a pointer one after the last element, and thus it's perfectly valid to hold it.

Quoted 2 lines

We could also argue that this should be implementation-defined behavior, or even unspecified behavior.

No, this is what we had in C17, and UB is much better than that. C17 destroyed the standard definition of realloc(p,0), even though it was supposed to be a no-op change. To some degree, I'm happy that that changed, as that brought us to now, where it is obvious that the only way forward is to go back to the traditional BSD specification.

Quoted 4 lines

However, the UBSG's current
arsenal for slaying earthly demons has traditionally not extended to changing what platforms do, as n3752 does. So IMO the UBSG should stand back and wait for n3752 to be resolved.

Have a lovely day!
Alex

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

--

David Svoboda [email protected]<mailto:[email protected]>

Senior Software Security Engineer

CERT Applied Systems Group

(412) 596-0401

Signature · 1 line
<https://www.alejandro-colomar.es>

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw

Hi Nevin,

Quoted 15 lines · Nevin Liber
Quoted 13 lines · David Svoboda

Here are some more thoughts on n3752
[...]
WRT this text:

Code written for platforms returning a null pointer can be
migrated to platforms returning non-null, without significant issues.

I am very skeptical that this is indeed true. But to be precise, this is Glibc's problem rather than WG14's. If they are willing to change glibc to return non-null on realloc(0), then I am willing to agree to this change in ISO C.

Quoted 6 lines
Quoted 3 lines

Is there any evidence that changing this behavior breaks no code? Any test failures? Any surveys?

And if it breaks no code, is that because this is a corner case that doesn't occur in practice?

It's not because of a corner case. It's because if it would go wrong, the worst that can happen is a memory leak of 0 bytes plus metadata (~16 B, usually).

And yes, it's a corner case, so it's not like you'll be leaking those 16 B regularly.

Quoted 1 line

That in itself doesn't mean we shouldn't change it.

The reason to change it is that with the current specification and implementation you can get serious vulnerabilities: remote code execution.

Also, that programming will be much easier if all implementations behave in the most simple way.

Quoted 8 lines
Quoted 4 lines

This paper ignores Windows other than to mention that it would need to
change too. I doubt MS will update MSVC to accommodate this paper. So
accepting this paper makes MSVC noncompliant.

This is the part that is troublesome to me. What is the point of changing this behavior if two (or even just one) major implementations are going to ignore it?

Do you know anyone from MS in WG21? It would be great to talk to them.

Have a lovely day!
Alex

Signature · 1 line
<https://www.alejandro-colomar.es>
#19 lore raw
In reply to a message not in the archive
Quoted 1 line · David Svoboda

Hi, Alex!

Hi David!

Quoted 9 lines

I'm just going to respond to your first point (about what precisely the UB is):

The n3605 Annex J text says:

(157) A non-null pointer returned by a call to the calloc, malloc, realloc, or aligned_alloc function with a zero requested size is used to access an object (7.25.4).

This suggests that working with a non-null pointer that has been returned from realloc() is the UB, not invoking realloc(0).

Quoted 7 lines

But 7.25.4.8 (realloc) text says:

Otherwise, if ptr does not match a pointer earlier returned by a memory management function, or if the space has been deallocated by a call to the free or realloc function, or if the size is zero, the behavior is undefined.

So you're right...UB comes from actually invoking realloc(), not working with whatever it returned. The Annex J wording needs some cleanup. Unless your paper gets accepted, in which case this Annex J UB goes away (and it wouldn't hurt to mention this in your paper, as we have found lots of obsolete UBs in Annex J).

Agree; UB 182 is already covered by the usual rules for NULL.

I thought you were talking about the UB introduced in C23, but that one seems not documented in Annex J. In fact, it's still documented incorrectly as ID (J.3.13 entry 41, in N3220).

The UB we should be talking about is specified in 7.24.3.7p3:

[...] Otherwise, [...], or if the size is zero, the behavior is undefined.

Have a lovely night!
Alex

Signature · 1 line
<https://www.alejandro-colomar.es>
#20 lore raw
Quoted 3 lines · Alejandro Colomar

I thought you were talking about the UB introduced in C23, but that one seems not documented in Annex J. In fact, it's still documented incorrectly as ID (J.3.13 entry 41, in N3220).

See
https://stackoverflow.com/questions/78691087/reallocptr-0-in-c23-now-what
regarding the lists of UB related to realloc being out of date. I think this could be fixed editorially via a merge request (to make the Annex J lists in C2y agree with the actual current realloc semantics in C2y) but I haven't got round to writing such an MR myself.

Signature · 2 lines
Joseph S. Myers
[email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#22 lore raw

Am Mittwoch, dem 07.01.2026 um 22:01 +0000 schrieb Joseph Myers:

Quoted 6 lines · Alejandro Colomar
Quoted 4 lines

I thought you were talking about the UB introduced in C23, but that one seems not documented in Annex J. In fact, it's still documented incorrectly as ID (J.3.13 entry 41, in N3220).

Quoted 6 lines

See
https://stackoverflow.com/questions/78691087/reallocptr-0-in-c23-now-what
regarding the lists of UB related to realloc being out of date. I think this could be fixed editorially via a merge request (to make the Annex J lists in C2y agree with the actual current realloc semantics in C2y) but I haven't got round to writing such an MR myself.

There know of various other issues and omissions in Annex J3. I think it would be good if the UB study group informally takes over maintenance of this annex.

Martin

A message that is not in the archive (sent off-list or not yet received): PH1P110MB16361EF635C579E30308D647CC85A@PH1P110MB1636.NAMP110.PROD.OUTLOOK.COM

#24 lore raw
Quoted 7 lines · David Svoboda

I would agree. I interpret "informally take over" to mean two things:

1. I would like someone to volunteer to scan the C2y draft standard (n3605) specifically to catch errors in Annex J.2. In particular, are there any UBs in J2 no longer in the standard. Likewise does the standard have any UBs not in J.2? The result would be a document recommending editorial changes to Annex J.2.

It's probably not just J.2. My guess is that J.1 (Unspecified behavior), J.3 (Implmentation-defined behavior) and J.4 (Locale-specific behavior) could all also be out of date relative to the normative contents of the standard.

In the case of checking for UBs, it needs to include "shall" or "shall not" outside constraints, whose violation is UB and ought to be listed as such in J.2 (when it's not a ghost - so when that "shall" or "shall not" expresses a requirement on C programs, not on implementations, that it is possible to violate without also violating a syntax rule or constraint), as well as places that explicitly say "undefined" in normative text. Also, some entries in J.2 may be things that are implicitly UB through lack of definition (so the absence of something in the normative text saying "undefined", "shall" or "shall not" isn't enough basis to remove something from J.2 editorially, you also need to locate the change that removed the UB from the normative text to demonstrate that there was an accidental failure to remove an entry from J.2).

Trickier cases where it's less clear why the entry was in J.2 in the first place, or where you need to argue that the entry is in fact a ghost, should still get papers. It's the ones that can be identified as accidental omissions to update Annex J (in either direction) when a change was made to the normative text that I think can be made editorially by merge requests without papers (and then if someone is concerned with such a change afterwards, they can request a revert and a paper to discuss it further).

I've wondered if it would be better to set up the LaTeX source of the standard so that the Annex J entries appear in the sources alongside the relevant parts of the normative text and get automatically collected for Annex J, rather than appearing separately in annex-port.tex, but that would be a big change and a lot of care would be needed not to lose any Annex J entries in the process.

Signature · 2 lines
Joseph S. Myers
[email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#26 lore raw

Hi Nevin,

Quoted 11 lines · Nevin Liber
Quoted 5 lines · Alejandro Colomar

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.

We cannot put requirements like this on future committees, nor is there anyone who can speak on behalf of future committees.

Agree.

Which is why the only solution is to actually fix the standard definition of realloc(3). And is also why POSIX will fork realloc(3) regardless of what ISO C says about it: currently, POSIX would be still compatible, because UB can be defined, but in the future, if ISO C deviates, the POSIX realloc(3) will be effectively a fork, and ISO C will be ignored.

If ISO C doesn't want to be forked, it only has an option: follow POSIX.

Quoted 2 lines

We can, of course, talk about the likelihood of this behavior changing again, strengthened by vote counts.

Yup.

Have a lovely night!
Alex

Quoted 3 lines
Signature · 2 lines
 Nevin ":-)" Liber  <mailto:[email protected] <[email protected]>>
+1-847-691-1404
Signature · 1 line
<https://www.alejandro-colomar.es>

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#29 lore raw

Hi Philipp,

Quoted 7 lines · Philipp Klaus Krause

Am 06.01.26 um 21:12 schrieb Robert Seacord:

Quoted 3 lines

I'm still waiting to hear from GCC that they plan to change the behavior of realloc and break their existing code.  If GCC plans to do this, it could well change my vote.

Not GCC here.

Quoted 7 lines

SDCC changed its malloc/realloc aligning it with Alejandro's proposal a few months ago, and the new behaviour will be in the next release (SDCC 4.6.0).

We made this decision after discussion among SDCC developers and users, and think that this is the best solution for SDCC and its users. We are not making any statement about this solution being appropriate for the standard or other implementations.

Wow! Thanks! That makes it two implementations that have already changed to adapt to this behavior after the proposal:

- SDCC (SDCC 4.6.0)
- gnulib (2024-11)

Plus of course the POSIX standard itself. That's looking good.

Have a lovely night!
Alex

Quoted 3 lines

Philipp

Signature · 1 line
<https://www.alejandro-colomar.es>