Deutsch   English   Français   Italiano  
<vlobp1$2dkpd$13@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Julio Di Egidio <julio@diegidio.name>
Newsgroups: comp.lang.c
Subject: Re: So You Think You Can Const?
Date: Thu, 9 Jan 2025 12:26:24 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <vlobp1$2dkpd$13@dont-email.me>
References: <vljvh3$27msl$1@dont-email.me> <vlma9m$2s5e5$1@dont-email.me>
 <vlo0cm$2dkpd$9@dont-email.me> <878qrkqll8.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 09 Jan 2025 12:26:25 +0100 (CET)
Injection-Info: dont-email.me; posting-host="e9d42356b81d42d02d68289eca9ecab3";
	logging-data="2544429"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19OKBi7laQFhF3iyLb58uA2F/op0b52gyc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:gBeOJskjZJwlvgBZmfFzbAxJcQE=
Content-Language: en-GB
In-Reply-To: <878qrkqll8.fsf@nosuchdomain.example.com>
Bytes: 2004

On 09/01/2025 12:21, Keith Thompson wrote:
> Julio Di Egidio <julio@diegidio.name> writes:
>> On 08/01/2025 17:48, Andrey Tarasevich wrote:
> [...]
>>> It is perfectly safe. One can even argue that standard declaration
>>> if `free` as `void free(void *)` is defective. It should have been
>>> `void free(const void *)` from the very beginning.
>>
>> I do not understand that: `free` is changing the pointed data, so how
>> can `const void *` even be "correct"?
> 
> No, `free` doesn't (necessarily) change the pointed-to data.
> Any attempt to access the allocated data after free() has undefined
> behavior, 

I would indeed call that a change!

Anyway I see the point, thanks for explaining.

-Julio

> so it might be modified, but all free() needs to do is
> make it available for further allocation.  It might do so without
> touching the data itself.