Bug 22072 – importC: Error: compound literal is not an lvalue and cannot be modified

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-22T19:42:39Z
Last change time
2022-09-20T04:53:11Z
Keywords
ImportC, rejects-valid
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2021-06-22T19:42:39Z
It can be used as an lvalue in an assignment in C """ 6.5.2.5-5 The value of the compound literal is that of an unnamed object initialized by the initializer list. If the compound literal occurs outside the body of a function, the object has static storage duration; otherwise, it has automatic storage duration associated with the enclosing block. """ Reduced test: --- struct S { int a; int b; }; void test() { (struct S) { 1, 2 } = (struct S) { 3, 4 }; }
Comment #1 by bugzilla — 2022-09-20T04:53:11Z
This compiles without complaint in master. The generated asm looks correct.