Deutsch English Français Italiano |
<86ttfp2zpf.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!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: Mon, 12 Aug 2024 14:33:48 -0700 Organization: A noiseless patient Spider Lines: 28 Message-ID: <86ttfp2zpf.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Mon, 12 Aug 2024 23:33:48 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f42e4005105099d89c60a754521770ce"; logging-data="3643568"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zMzF/piFtGeCNN42nzPAMjoTmVmC/WlM=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:gq/J/Stu2W/utxoapNrMem4GlNU= sha1:AX1H7oVUIwORyLrkKqebmk1Ks1c= Bytes: 2292 Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: > candycanearter07 <candycanearter07@candycanearter07.nomail.afraid> > writes: > >> David Brown <david.brown@hesbynett.no> wrote at 17:56 this Thursday (GMT): > > [...] > >>> gcc has the option "-Wwrite-strings" that makes string literals in >>> C have "const char" array type, and thus give errors when you try >>> to assign to a non-const char * pointer. But the option has to be >>> specified explicitly (it is not in -Wall) because it changes the >>> meaning of the code and can cause compatibility issues with >>> existing correct code. >> >> -Wwrite-strings is included in -Wpedantic. > > No it isn't, nor is it included in -Wall -- and it wouldn't make > sense to do so. > > The -Wpedantic option is intended to produce all required > diagnostics for the specified C standard. -Wwrite-strings > gives string literals the type `const char[LENGTH]`, which > enables useful diagnostics but is *non-conforming*. As long as the -Wwrite-strings diagnostics are only warnings the result is still conforming.