https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103483

--- Comment #5 from John McFarlane <john at mcfarlane dot name> ---
Here is an example of the real-world code causing this warning:
https://github.com/johnmcfarlane/cnl/blob/6d46b6cf10a998e3bdcc32557f202c8579b5717c/test/unit/scaled_int/to_chars.h#L60

It is converting a numeric type to a string with a `to_chars`-like API. It's
entirely feasible that a user might wish to convert a number to a 1-digit
string and encounter a false positive. I've tried adding the recommended
`__builtin_unreachable()` statement at several points in `test` and
`to_chars_natural` and it doesn't suppress the warning.

The best course of action I can see is to disable the warnings for GCC-12 and
beyond:
https://github.com/johnmcfarlane/cnl/blob/main/test/toolchain/gcc-head.cmake#L5
I feel that this is counterproductive.

Reply via email to