free(3) const void *

Andreas Schwab schwab@linux-m68k.org
Fri Jan 26 22:07:50 GMT 2024


On Jan 26 2024, DJ Delorie wrote:

> Andreas Schwab <schwab@linux-m68k.org> writes:
>> Also, objects in the heap are never read-only.
>
> I thought of that, but using "const" in a program can mean something
> other than "the object is read-only".

Right, that is the difference between const-qualified and read-only.

> It can also act as a promise to the user and/or optimizer that an
> object is not written to, even if doing such is possible.

Unfortunately, the C standard does not support that promise.  Only
static or automatic objects can be truely read-only.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


More information about the Libc-alpha mailing list