[clang] [Clang] Fix conversion from floats to bool-backed enums per CWG1094 (PR #211172)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 22 03:41:15 PDT 2026


================
@@ -111,3 +119,34 @@ namespace cwg1070 { // cwg1070: 3.5
   C c = {};
 #endif
 } // namespace cwg1070
+
+#if __cplusplus >= 201103L
+namespace cwg1094 { // cwg1094: 24
+enum class E : bool { Zero, One };
----------------
Endilll wrote:

CWG1094 is not limited to enums with the underlying type of `bool`, so I want to see a similar set of test cases, but with enum whose fixed underlying type is `int`.

Furthermore, I'm not sure I agree with the description of CWG1094 saying that the old [expr.static.cast]/7 ("The inverse of any standard conversion sequence...") is handling enums without a fixed underlying type, as this paragraph was removed recently in [CWG2987](https://cplusplus.github.io/CWG/issues/2987.html) "Remove dilapidated wording from `static_cast`".

Separately, since we're looking closely at this wording, I think we should mark [CWG1739](https://cplusplus.github.io/CWG/issues/1739.html) "Conversion of floating point to enumeration" as N/A.

https://github.com/llvm/llvm-project/pull/211172


More information about the cfe-commits mailing list