Comments
Patch
commit 373e79aaea9c5b73cebeb1e8fd4fedbdfd553a35
Author: Jason Merrill <jason@redhat.com>
Date: Fri Sep 14 09:48:48 2012 -0400
PR c++/53661
* typeck2.c (check_narrowing): Avoid false positives on conversion
from enumeral type.
@@ -787,6 +787,9 @@ check_narrowing (tree type, tree init)
else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
&& CP_INTEGRAL_TYPE_P (type))
{
+ if (TREE_CODE (ftype) == ENUMERAL_TYPE)
+ /* Check for narrowing based on the values of the enumeration. */
+ ftype = ENUM_UNDERLYING_TYPE (ftype);
if ((tree_int_cst_lt (TYPE_MAX_VALUE (type),
TYPE_MAX_VALUE (ftype))
|| tree_int_cst_lt (TYPE_MIN_VALUE (ftype),
new file mode 100644
@@ -0,0 +1,9 @@
+// PR c++/53661
+
+enum Code {
+ SUCCESS = 0
+};
+
+Code a;
+
+int r[] = {a};