[Bug c++/122772] [13/14 Regression] Bit-field expressions resulting from assignment operators and comma operators are incorrectly rejected when used as the first operand of a compound assignment operator since r7-1689
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 15 06:04:29 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122772
--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:a946e2e7166015a1c9c78233201459be20d92258
commit r14-12381-ga946e2e7166015a1c9c78233201459be20d92258
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Dec 19 11:24:02 2025 +0100
c++: Fix stabilization of bitfields [PR122772]
The following testcase is rejected, because due to the C++17
b @= a ordering of side-effects cp_stabilize_reference is called
on the lhs of the compound assignment. For some cases
cp_stabilize_reference just uses stabilize_reference, but for other
cases it attempts to bind a reference to the expression.
This doesn't work for bit-fields and DECL_PACKED fields though,
we can't take address of a bit-field (nor DECL_PACKED field)
and error on that.
This patch introduces for this another wrapper around
stabilize_reference, which for clk_bitfield | clk_packed handles
some trees stabilize_reference doesn't handle correctly for C++,
and for the rest defers to stabilize_reference.
This way, we can introduce multiple SAVE_EXPRs (like stabilize_expr
itself already can as well), but can handle even the weirdest
lhs expressions for which lvalue_kind returns clk_bitfield or clk_packed
set.
2025-12-19 Jakub Jelinek <jakub@redhat.com>
PR c++/122772
* tree.cc (cp_stabilize_bitfield_reference): New function.
(cp_stabilize_reference): Use it for stabilization of
clk_bitfield or clk_packed lvalues.
* g++.dg/cpp1z/eval-order14.C: New test.
(cherry picked from commit 1eb6a757b060087731162d821410a9b384568079)
More information about the Gcc-bugs
mailing list