mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-10-24 02:08:57 +03:00
Change some uses of unreachable() to affirm(false), so that we would get an abort in normal builds. This is safer than unreachable() which results in undefined behavior. See commit v9.8-27-ge661c7a52 for a real case of this. Uses of unreachable() should be provably unreachable, and trivially so. Trivial cases: e.g. after error(NON_ZERO, ...) etc, or a fully handled switch on enum (proved with -Wswitch-enum). Note unreachable() can be defined to exit with -funreachable-traps, but it's better to use standard build options and distinguish the different classes of "unreachable" in code. Also clang (22) doesn't seem to support the -funreachable-traps option. Note we prefer affirm to abort, since it has better diagnostics in the normal case and better performance with -DNDEBUG. and prefer affirm to assert, as it allows for better static checking when compiling with -DNDEBUG. Neither of these apply to affirm(false), but we avoid assert for consistency. * gl/lib/mbbuf.h: s/unreachable/affirm(false)/. * src/copy-file-data.c: Likewise. * src/copy.c: Likewise. * src/cut.c: Likewise. * src/ls.c: Likewise. * src/numfmt.c: Likewise. * src/od.c: Likewise. * src/stdbuf.c: Likewise. * src/sync.c: Likewise. * src/tr.c: Likewise. * src/tsort.c: Likewise. * src/wc.c: Likewise.