[gcc r14-11995] libstdc++: Fix -Wswitch warning in <regex>
Jonathan Wakely
redi@gcc.gnu.org
Wed Sep 3 08:43:28 GMT 2025
https://gcc.gnu.org/g:343f177943e2b0a9025fe7cc1b5e95c283248124
commit r14-11995-g343f177943e2b0a9025fe7cc1b5e95c283248124
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Sep 1 22:22:20 2025 +0100
libstdc++: Fix -Wswitch warning in <regex>
This fixes a warning seen with -Wsystem-headers:
include/c++/14.3.0/bits/regex_compiler.h:191:11: warning: case value '0' not in enumerated type 'std::regex_constants::syntax_option_type' [-Wswitch]
191 | case _FlagT(0):
| ^~~~
There's no diagnostic on trunk since the flag_enum attribute was added
to the enum type in r15-3500-g1914ca8791ce4e.
libstdc++-v3/ChangeLog:
* include/bits/regex_compiler.h (_Compiler::_S_validate): Add
diagnostic pragma to disable -Wswitch warning.
Diff:
---
libstdc++-v3/include/bits/regex_compiler.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
index 5501d709e854..c6aaf4408531 100644
--- a/libstdc++-v3/include/bits/regex_compiler.h
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -188,8 +188,11 @@ namespace __detail
case grep:
case egrep:
return __f;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch" // do not warn about non-enumerator
case _FlagT(0):
return __f | ECMAScript;
+#pragma GCC diagnostic pop
default:
std::__throw_regex_error(_S_grammar, "conflicting grammar options");
}
More information about the Libstdc++-cvs
mailing list