Deutsch English Français Italiano |
<87wmklh0dn.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.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: No warning at implicit removal of const. Was: relearning C: why does an in-place change to a char* segfault? Date: Mon, 12 Aug 2024 14:55:32 -0700 Organization: None to speak of Lines: 41 Message-ID: <87wmklh0dn.fsf@nosuchdomain.example.com> References: <IoGcndcJ1Zm83zb7nZ2dnZfqnPWdnZ2d@brightview.co.uk> <20240801174026.00002cda@yahoo.com> <v8gi7i$29iu1$1@dont-email.me> <slrnvaorkl.34j6.candycanearter07@candydeb.host.invalid> <87zfpvfdk4.fsf@nosuchdomain.example.com> <v8ii17$2q5p1$1@dont-email.me> <87v80ig4vt.fsf@nosuchdomain.example.com> <86plqd2zhf.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 12 Aug 2024 23:55:33 +0200 (CEST) Injection-Info: dont-email.me; posting-host="95de69de4fa23f7b87735178c0e02b79"; logging-data="3661514"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jgX6ZOrpZdh83UosTthYq" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:B0PJa4jkdS+y1uGMhNc9iVGwMpU= sha1:V5lWfW3JTKd8D/JodJPJ5xf7X9o= Bytes: 2743 Tim Rentsch <tr.17687@z991.linuxsc.com> writes: > Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: > >> Richard Harnden <richard.nospam@gmail.invalid> writes: >> [...] >> >>> Is there any reason not to always write ... >>> >>> static const char *s = "hello, world"; >>> >>> ... ? >>> >>> You get all the warnings for free that way. >> >> The "static", if this is at block scope, specifies that the >> pointer object, not the array object, has static storage duration. >> If it's at file scope it specifies that the name "s" is not >> visible to other translation units. Either way, use it if that's >> what you want, don't use it if it isn't. >> >> There's no good reason not to use "const". [...] > > Other people have different opinions on that question. You could have told us your opinion. You could have explained why someone might have a different opinion. You could have given us a good reason not to use "const", assuming there is such a reason. You know the language well enough to make me suspect you might have something specific in mind. That could have been interesting and useful. Instead, you chose to waste everyone's time with a practically content-free response. Yes, different people have different opinions. Golly, I never knew that. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */