]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Avoid -Wswitch warning from chrono formatters
authorJonathan Wakely <jwakely@redhat.com>
Fri, 4 Jul 2025 16:03:27 +0000 (17:03 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 4 Jul 2025 23:08:28 +0000 (00:08 +0100)
Add a default case to the switch to suppress warnings about unhandled
enumeration values. This is a consteval function, so if the default case
is ever reached it will be an error not silent miscompilation.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_duration::_S_spec_for):
Add default case to switch and use __builtin_unreachable.

libstdc++-v3/include/bits/chrono_io.h

index bcf9830fb9e23890c28e5c0b0e3358b5c17283bb..72cd569ccd65dcf68b98073366fa3924f2117a6b 100644 (file)
@@ -1841,6 +1841,8 @@ namespace __format
              break;
            case _None:
              break;
+           default:
+             __builtin_unreachable();
            }
          return __res;
        };