[Bug c++/81607] Conditional operator: "type mismatch in shift expression" error

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jul 31 09:44:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81607

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'm actually testing this

--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2314,9 +2314,9 @@ cp_fold (tree 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);
+      if (TREE_CODE (x) != code
+     && !useless_type_conversion_p (TREE_TYPE (org_x), TREE_TYPE (x)))
+   x = fold_convert (TREE_TYPE (org_x), x);

       break;

so I hope that case is covered.  We'll see.


More information about the Gcc-bugs mailing list