Deutsch English Français Italiano |
<8734n5fjtq.fsf@nosuchdomain.example.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: 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: Thu, 15 Aug 2024 16:27:29 -0700 Organization: None to speak of Lines: 64 Message-ID: <8734n5fjtq.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> <v8gte2$2ceis$2@dont-email.me> <20240801174256.890@kylheku.com> <v8i9o8$2oof8$1@dont-email.me> <v8j808$2us0r$1@dont-email.me> <864j7oszhu.fsf@linuxsc.com> <87o75vg9ot.fsf@nosuchdomain.example.com> <86ikw1o0h8.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 16 Aug 2024 01:27:30 +0200 (CEST) Injection-Info: dont-email.me; posting-host="1d04e40206551ed72fc82578ee5a10bf"; logging-data="1197689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OVx/f2Lk2q445tp3ou4nN" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:RMR1vsXykomnCv6RittzO1cllmY= sha1:QwV85NIYlgBq2EuflumHEyTcYY8= Bytes: 4058 Tim Rentsch <tr.17687@z991.linuxsc.com> writes: > Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: > >> Tim Rentsch <tr.17687@z991.linuxsc.com> writes: >> >>> James Kuyper <jameskuyper@alumni.caltech.edu> writes: >>> >>>> Just as 1 is an integer literal whose value cannot be modified, >>>> [...] >>> >>> The C language doesn't have integer literals. C has string >>> literals, and compound literals, and it has integer constants. >>> But C does not have integer literals. >> >> Technically correct (but IMHO not really worth worrying about). > > Anyone who flogs others posters for incorrectly using terminology > defined in the ISO C standard should set a good example by using > the ISO-C-defined terms correctly himself. In fact I do. In my own writing, I use the term "integer constant", not "integer literal", when discussing C. (It's likely I haven't been 100% consistent.) My point is that, while "integer literal" is inconsistent with the terminology used in the C standard, it is not ambiguous or confusing. C does not define the term "literal" (it defines the phrases "string literal" and "compound literal"). The word "literal" by itself is a very common term used when discussing programs in general. When I looked into it last time this came up, I found that most of the programming languages I looked into refer to 42 as a literal, not as a constant. I'll also note that the word "constant" is overloaded in C. For example, as of C17, the description of "sizeof" says: "If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant." Though the meaning is clear, it's an incorrect usage. (C23 changes this to "... and the result is an integer constant expression", which is better, but it's the expression, not its result, that is an integer constant expression.) Replacing the term "constant" by "literal" would, in my opinion, improve the clarity of the standard. I see no drawbacks to such a change (other than the overhead of *any* change to the standard). >> There is a proposal for C2y, authored by Jens Gustedt, to change the >> term "constant" to "literal" for character, integer, and floating >> constants. (I think it's a good idea.) >> >> <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3239.htm> > > The more C is changed to resemble C++ the worse it becomes. It > isn't surprising that you like it. I presume that was intended as a personal insult. I urge you to do better. I acknowledge your opinion. I do not share it. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */