commit c1b91b53f85c8a00c5067dbfc15f5fb0da7da4f6
Author: Jason Merrill <jason@redhat.com>
Date: Mon Mar 21 15:54:51 2016 -0400
PR c++/70285
* cp-gimplify.c (cp_fold) [COND_EXPR]: Handle bit-fields.
@@ -2130,6 +2130,12 @@ cp_fold (tree x)
else
x = fold (x);
+ /* A COND_EXPR might have incompatible types in branches if one or both
+ arms are bitfields. If folding exposed such a branch, fix it up. */
+ if (TREE_CODE (x) != code)
+ if (tree type = is_bitfield_expr_with_lowered_type (x))
+ x = fold_convert (type, x);
+
break;
case CALL_EXPR:
new file mode 100644
@@ -0,0 +1,15 @@
+// PR c++/70285
+
+int a;
+
+struct S
+{
+ int i:8;
+} b;
+
+int
+fn1 (bool x)
+{
+ (&fn1 ? b.i : a) = 42;
+ return (&fn1 ? b.i : a);
+}