Groups | Search | Server Info | Login | Register
Groups > comp.lang.c > #398044
| From | cross@spitfire.i.gajendra.net (Dan Cross) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Small challenge: sort names |
| Date | 2026-04-27 20:43 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <10sohpc$444$1@reader1.panix.com> (permalink) |
| References | <10r4h6o$396qn$1@dont-email.me> <10soe78$2kmgo$1@dont-email.me> <10soe9m$2l223$1@dont-email.me> <10sof6k$2l43i$1@kst.eternal-september.org> |
In article <10sof6k$2l43i$1@kst.eternal-september.org>, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes: >> On 4/27/2026 12:42 PM, Chris M. Thomasson wrote: >[...] >>> Fwiw, I only use '\0' for the null terminator in strings, not for >>> pointers... > >I'm not sure why that's worth mentioning. The only reason I can >think of to use '\0' for pointers is deliberate obfuscation, or >*maybe* testing how a compiler handles it. Some time ago, a rather famous production outage at Google was the result of something very similar. The author wrote, ptr->some_bool = false; where what was meant was, *ptr->some_bool = false; Here, `some_bool` was `bool *some_bool`. Perfectly legal, of course: `false` was just a macro expanding to the integer constant 0, which in pointer context is a null pointer constant, thus setting `some_bool` to the null pointer. But clearly what was meant was to assign false to the actual boolean. Oops. At the time, the compiler (gcc) did not emit a diagnostic for this, but `clang` did. The build system was quickly changed to invoke both; showing combined diagnostics from both compilers, but keeping only the object file emitted by gcc (as I understand it, Google has since switched to using `clang` as the default compiler in its monorepo). This, and similar incidents, are one reason I greatly prefer domain-specific constructs (e.g, '\0' for character data instead of plain ol' 0) and explicit comparisons (`if (ptr != NULL)` vs `if (ptr)`). Over time and at large enough scale, these things really do start to matter. >> Or NUL for strings? > >NUL is a name for the null character, but there's no such identifier >in the C standard language or library. FWIW, observation over some time makes me think that the person to whom you are responding is driving with an engine that is not quite firing on all cylinders. His posts are usually non sequiturs, and he tends to reply to himself often. He's not offensive or anything, so I haven't plonked him, but I try to refrain from engaging with him. - Dan C.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Small challenge: sort names Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-04-25 13:31 -0700
Re: Small challenge: sort names Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-04-25 15:12 -0700
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-26 04:13 +0200
Re: Small challenge: sort names Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-04-25 19:50 -0700
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-26 05:28 +0200
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-26 12:08 +0200
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-26 18:16 +0200
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-26 19:37 +0200
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-27 02:17 +0200
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-27 09:19 +0200
Re: Small challenge: sort names scott@slp53.sl.home (Scott Lurndal) - 2026-04-26 17:47 +0000
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-27 02:33 +0200
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-27 09:34 +0200
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-27 12:35 +0200
Re: Small challenge: sort names Bart <bc@freeuk.com> - 2026-04-27 13:28 +0100
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-27 17:02 +0200
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-27 17:36 +0200
Re: Small challenge: sort names scott@slp53.sl.home (Scott Lurndal) - 2026-04-27 16:18 +0000
Re: Small challenge: sort names Michael S <already5chosen@yahoo.com> - 2026-04-27 11:42 +0300
Re: Small challenge: sort names scott@slp53.sl.home (Scott Lurndal) - 2026-04-27 16:27 +0000
Assembler verb choice (Was: Small challenge: sort names) gazelle@shell.xmission.com (Kenny McCormack) - 2026-04-28 12:59 +0000
Re: Assembler verb choice (Was: Small challenge: sort names) Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-28 16:26 +0200
Re: Small challenge: sort names "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-04-27 12:45 -0700
Re: Small challenge: sort names "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-04-27 12:42 -0700
Re: Small challenge: sort names "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-04-27 12:43 -0700
Re: Small challenge: sort names Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-04-27 12:59 -0700
Re: Small challenge: sort names "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-04-27 13:26 -0700
Re: Small challenge: sort names cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-27 20:43 +0000
Re: Small challenge: sort names "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-04-27 17:30 -0700
Re: Small challenge: sort names Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-04-27 19:15 -0700
Re: Small challenge: sort names gazelle@shell.xmission.com (Kenny McCormack) - 2026-04-28 12:01 +0000
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-28 08:35 +0200
Re: Small challenge: sort names cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-28 13:27 +0000
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-28 15:59 +0200
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-28 16:49 +0200
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-28 17:25 +0200
Re: Small challenge: sort names Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-28 23:46 +0200
Re: Small challenge: sort names cross@spitfire.i.gajendra.net (Dan Cross) - 2026-04-28 18:12 +0000
Re: Small challenge: sort names David Brown <david.brown@hesbynett.no> - 2026-04-28 20:28 +0200
Re: Small challenge: sort names vallor <vallor@vallor.earth> - 2026-04-28 13:45 +0000
csiph-web