Deutsch   English   Français   Italiano  
<v9hqh5$cnbt$1@dont-email.me>

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

Path: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: relearning C: why does an in-place change to a char* segfault?
Date: Wed, 14 Aug 2024 10:40:05 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <v9hqh5$cnbt$1@dont-email.me>
References: <IoGcndcJ1Zm83zb7nZ2dnZfqnPWdnZ2d@brightview.co.uk>
 <v8fhhl$232oi$1@dont-email.me> <v8fn2u$243nb$1@dont-email.me>
 <87jzh0gdru.fsf@nosuchdomain.example.com> <865xs54fak.fsf@linuxsc.com>
 <v9fqtb$3t7ph$4@dont-email.me> <8734n8gp8v.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Aug 2024 10:40:07 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="e46c08485c7f38051ccb446836275479";
	logging-data="417149"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+AemQEx4MVk7la/cRXyG0kytuxyFeasRk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:7djeCX+7BA+I7lIlHLLArb8E5Fw=
In-Reply-To: <8734n8gp8v.fsf@nosuchdomain.example.com>
Content-Language: en-GB
Bytes: 2077

On 13/08/2024 22:08, Keith Thompson wrote:

> In 20/20 hindsight, my personal opinion is that it would have been
> better to make string literals const in C89/C90.  Compilers could
> still accept old const-incorrect code with a non-fatal warning,
> and programmers would be encouraged but not immediately forced to
> use const.
> 

Agreed.

That's basically what happened when C++ was designed.

> This could still be done in C2y, but I'm not aware of any proposals.
> 

There is always going to be some hassle with things like search 
functions - 100% const correctness is not easy when you don't have 
overloads.  (It's not always easy even in C++ where you /do/ have 
overloads and templates.)