Deutsch English Français Italiano |
<861q20q3tz.fsf@linuxsc.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: Tim Rentsch <tr.17687@z991.linuxsc.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: Tue, 03 Sep 2024 06:11:52 -0700 Organization: A noiseless patient Spider Lines: 35 Message-ID: <861q20q3tz.fsf@linuxsc.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> <87wmklh0dn.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 03 Sep 2024 15:11:53 +0200 (CEST) Injection-Info: dont-email.me; posting-host="5dc3c968fdc353e2fd687882edf89fc4"; logging-data="3505173"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19s0f/2NdN8lklnkR1sfsWjQWdv+mEHTUc=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:vcH9MqIsNOTjZ2Y5KeLcvOmzeZk= sha1:2yIfT5k7HBZOVacYi3UcpfA2Lb4= Bytes: 2646 Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: > 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. [...] I said all that I thought needed saying. I see no reason to add to it.