Deutsch English Français Italiano |
<87jzgjg9k3.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feeds.phibee-telecom.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: relearning C: why does an in-place change to a char* segfault? Date: Tue, 13 Aug 2024 18:47:08 -0700 Organization: None to speak of Lines: 22 Message-ID: <87jzgjg9k3.fsf@nosuchdomain.example.com> 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> <86h6boszrb.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 14 Aug 2024 03:47:08 +0200 (CEST) Injection-Info: dont-email.me; posting-host="8fd33d9227c54bb33f07e63da240e3d2"; logging-data="294359"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1978Sx6yQbXB4WaRzZlZCaN" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:tNYvdymF/BcTuVT2V2R06AFQFAc= sha1:SDtzPULmt1jPVj3Pr+nJipbTRDk= Bytes: 2355 Tim Rentsch <tr.17687@z991.linuxsc.com> writes: [...] > C was already well established before 'const' was invented, and it > was a number of years after that before some C compilers started > allowing 'const' in source code. The cost of not being backward > compatible would be high; the cost adding const incrementally in > new code is low. Generally speaking using string literals in open > code is a bad idea anyway, regardless whether there is any concern > that the string might be modified. I think most people who want > string literals to be of type const char[] are only thinking about > one side of the equation. It's always important to remember to > look at both sides of the cost/benefit forces, and not focus on > just the (imagined) benefits or (imagined) downsides. I can't speak for most people, but I want string literals to be const and I've thought about both sides of the equation. (Existing code could be compiled with options to enable the old behavior and could be changed incrementally.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */