Paul Eggert <[email protected]> writes:

> On 2025-09-18 14:48, Collin Funk wrote:
>> What is the difference between
>> affirm (false) and unreachable ()?
>
> There's no difference if you define NDEBUG, but in the normal case
> where if NDEBUG is not defined, affirm (false) is like assert (false).
>
>> I find unreachable () to convey the meaning much better.
>
> Me too.
>
> I suspect that coreutils' uses of 'affirm (false)' predate the
> introduction 'unreachable'. I'd also prefer to change them to
> 'unreachable ()'. However, we have yet to hear from any fans of
> 'assert'.

Does GCC have an option to make 'unreachable ()' abort?

I know that the C23 standard says it is undefined, so implementations
can do as they wish. But the behavior I think is best would be to use it
as a compiler hint by default, then have a flag for developers to have
it behave like 'abort ()'. That way developers can catch any bugs they
did not forsee when marking it unreachable.

Regardless, I will leave things as-is until after the release. No point
in changing what isn't broken at the moment.

Collin

Reply via email to