[committed] libstdc++: Avoid -Wswitch warning from chrono formatters

Jonathan Wakely jwakely@redhat.com
Fri Jul 4 23:08:58 GMT 2025


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.
---

Tested x86_64-linux. Pushed to trunk.

 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;
 	};
-- 
2.50.0



More information about the Libstdc++ mailing list