This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]