Deutsch English Français Italiano |
<87h6curv5a.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: question about nullptr Date: Fri, 12 Jul 2024 17:30:09 -0700 Organization: None to speak of Lines: 35 Message-ID: <87h6curv5a.fsf@nosuchdomain.example.com> References: <v6bavg$3pu5i$1@dont-email.me> <20240706054641.175@kylheku.com> <v6ragn$318o9$1@dont-email.me> <20240712144910.90@kylheku.com> <c5ikO.4361$h64d.3054@fx40.iad> <20240712161502.715@kylheku.com> <8CjkO.23218$xYQc.22075@fx12.iad> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 13 Jul 2024 02:30:10 +0200 (CEST) Injection-Info: dont-email.me; posting-host="4a3d257843ab23dd94816a3c655c4d6d"; logging-data="3407492"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FW2SzTfZMDUyFBRLBcVqK" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:BYNmQxY6HzNbW7y+EvyOA/v4MXg= sha1:hSAoNv4otn+Txyocbr3K7nI+DCk= Bytes: 2822 scott@slp53.sl.home (Scott Lurndal) writes: > Kaz Kylheku <643-408-1753@kylheku.com> writes: >>On 2024-07-12, Scott Lurndal <scott@slp53.sl.home> wrote: >>> Kaz Kylheku <643-408-1753@kylheku.com> writes: >>>>On 2024-07-12, Richard Harnden <richard.nospam@gmail.invalid> wrote: >>>>> Don't you use '\n'? Surely nobody would say 0x0a? >>> >>>>But, see, nobody in their right mind would say '\012` for that. '\0' >>>>an octal escape sequence like '\012', not a role-based character >>>>abstraction like '\n'. > > Because '\012' is a character. 012 is an int. Using the former > ensures that any overflow will be detected at compile time and make > it clear to any future reader that the author intended it to be a > character, not an integer. '\012' is a character constant. 012 is an integer constant. Both are of type int, and both have the same value, 10. It's true that an octal character constant with a value exceeding UCHAR_MAX is a constraint violation (like '\400' if UCHAR_MAX is 255), and if you provide more than 3 digits the result is a multi-character constant, which is likely to trigger a warning. But any overflow would almost certainly be the result of a typo, and guarding against that doesn't strike me as a good reason to use one kind of constant over another. Having said that, I absolutely do prefer to use character constants for character data ('\012' or '\x0a' if I want a character with value 10, or more likely '\n' if I want a newline). But that's for the benefit of the reader, not of the compiler. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */