https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127765
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jsm28 at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That particular COMPOUND_EXPR is indeed not needed if !TREE_SIDE_EFFECTS
(arg1), the only purpose of it is to evaluate arg1 outside of the conditional
if it is a SAVE_EXPR or something containing it, so that it isn't first
encountered inside of one of the conditional branches.
--- a/gcc/c-parser.cc 2026-10-07 10:13:07.486347391 +0200
+++ b/gcc/c-parser.cc 2026-10-08 17:33:32.414182333 +0200
@@ -13372,8 +13372,9 @@ c_parser_postfix_expression (c_parser *p
tree t4 = build2_loc (loc, NE_EXPR, boolean_type_node,
arg2,
build_zero_cst (TREE_TYPE (arg2)));
- t4 = build2_loc (loc, COMPOUND_EXPR, boolean_type_node,
- arg1, t4);
+ if (TREE_SIDE_EFFECTS (arg1))
+ t4 = build2_loc (loc, COMPOUND_EXPR, boolean_type_node,
+ arg1, t4);
expr.value = build3_loc (loc, COND_EXPR,
TREE_TYPE (arg1), t4, t3, arg1);
}
fixes
const unsigned _BitInt(3) a = __builtin_stdc_rotate_left (2uwb, 1);
const unsigned _BitInt(67) b = __builtin_stdc_rotate_right
(112787102298290611607uwb, 1);
const unsigned _BitInt(3) c = __builtin_stdc_rotate_left (3uwb - 1uwb, 624 -
623);
const unsigned _BitInt(67) d = __builtin_stdc_rotate_right
(112787102298290611601uwb + 2uwb * 3uwb, -50 + 51);
compilation, but not
constexpr unsigned _BitInt(3) a = __builtin_stdc_rotate_left (2uwb, 1);
constexpr unsigned _BitInt(67) b = __builtin_stdc_rotate_right
(112787102298290611607uwb, 1);
constexpr unsigned _BitInt(3) c = __builtin_stdc_rotate_left (3uwb - 1uwb, 624
- 623);
constexpr unsigned _BitInt(67) d = __builtin_stdc_rotate_right
(112787102298290611601uwb + 2uwb * 3uwb, -50 + 51);
static_assert (a == 1uwb);
static_assert (b == 130180527443983512267uwb);
static_assert (a == c);
static_assert (b == d);
I'm not sure if the latter should be valid or not.