This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81607] Conditional operator: "type mismatch in shift expression" error
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 31 Jul 2017 09:44:09 +0000
- Subject: [Bug c++/81607] Conditional operator: "type mismatch in shift expression" error
- Auto-submitted: auto-generated
- References: <bug-81607-4@http.gcc.gnu.org/bugzilla/>
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.