[gcc r16-2030] libstdc++: Avoid -Wswitch warning from chrono formatters
Jonathan Wakely
redi@gcc.gnu.org
Fri Jul 4 23:08:45 GMT 2025
https://gcc.gnu.org/g:eeea445e1d0f0aac813d4eccd7b8f55477772dd0
commit r16-2030-geeea445e1d0f0aac813d4eccd7b8f55477772dd0
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Jul 4 17:03:27 2025 +0100
libstdc++: Avoid -Wswitch warning from chrono formatters
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.
Diff:
---
libstdc++-v3/include/bits/chrono_io.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h
index bcf9830fb9e2..72cd569ccd65 100644
--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -1841,6 +1841,8 @@ namespace __format
break;
case _None:
break;
+ default:
+ __builtin_unreachable();
}
return __res;
};
More information about the Libstdc++-cvs
mailing list