Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Are there any conformant C compilers? Date: Sat, 03 Sep 2022 12:52:33 -0700 Organization: None to speak of Lines: 27 Message-ID: <87o7vwkzge.fsf@nosuchdomain.example.com> References: <871qswsdn2.fsf@bsb.me.uk> <87h71spdn3.fsf@bsb.me.uk> <87tu5snu4o.fsf@bsb.me.uk> <87ilm4fzau.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="bfa3159622d8695b1dca10d6764500ef"; logging-data="3127811"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tLrBvMNaNaay57PDA3hQL" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:/XldjdIOVL99lI+4vUFI8BV0CnA= sha1:TA45iGTXHmAQn9pWFFPAfSNTkH0= Xref: csiph.com comp.lang.c:167467 Ben Bacarisse writes: > David Brown writes: > >> ... Of course that's an extreme viewpoint - in any programming, in >> any language, you have to assume that people are writing sensible code >> (except perhaps at guarded interfaces) or you'll get nowhere. And any >> object defined const /will/ be constant, unless you wield one of C's >> sledgehammers at your own foot. > > Some of C's 'sledgehammers' are dressed up as simple everyday tools: > > extern void edit_string_tail(char *string); > ... > const char name[] = "Molly Dog"; > edit_string_tail(strchr(name, ' ')); C23 addresses this by making strchr and several other functions generic, so that the result is a pointer to const if and only if the argument is a pointer to const. (Presumably this is implemented using macros and _Generic.) , section 7.26.5 -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */