https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122772
Bug ID: 122772
Summary: Bit-field expressions resulting from assignment
operators and comma operators are incorrectly rejected
when used as the first operand of a compound
assignment operator
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: luigighiron at gmail dot com
Target Milestone: ---
The following program is incorrectly rejected by GCC:
int main(){
struct{int x:4;}x;
(x.x=0)+=0;
}
Replacing (x.x=0) with (0,x.x) or (x.x+=0) also results in GCC incorrectly
rejecting the program. This appears to be unique to compound assignment
operators, ++(x.x=0) and (x.x=0)=0 are both accepted. Conditional operators
don't seem to cause this issue, for example (1?x.x:x.x)+=0 is correctly
accepted. However, it does seem to propagate the issue if either of the second
or third operands on their own would cause the issue e.g. (1?0,x.x:x.x)+=0 is
incorrectly rejected.
Clang and MSVC both accept this. Also it appears to work before GCC 7.