News for hackers. Stuff that matters.
Re:Catch-23: The New C Standard Sets the World on Fire by GuB-42 on Sunday April 02, 2023 @09:24AM (#35410259)
AFAIK, assert() is not undefined behavior, so it can't be used for optimization. It is either implementation-defined in debug mode, or does nothing in release mode.

For example:

  assert(a >= 0);
  if (a < 0) printf("a is negative");
In release mode, assert() will be gone, so the if/printf() will stay. If we used "if (a < 0) unreachable();" instead of assert(), it would optimize away both lines.

There are no comments on this comment yet.