Bug 17491 – Compiles on invalid: *&s.init.var is not an lvalue
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-11T13:47:00Z
Last change time
2017-08-07T13:16:42Z
Assigned to
ibuclaw
Creator
ibuclaw
Comments
Comment #0 by ibuclaw — 2017-06-11T13:47:51Z
Test case:
---
struct S
{
int i;
}
void bug()
{
S.init = S(42); // OK -> (S).init is not an lvalue
*&S.init = S(42); // OK -> S(0) is not an lvalue
S.init.i = 42; // OK -> constant S(0).i is not an lvalue
*&S.init.i = 42; // Compiles!
}
---
Having a look at the AST dump:
---
import object;
struct S
{
int i;
}
void bug()
{
0 = 42; // <- This should be a compiler error.
}
RTInfo!(S)
enum typeof(null) RTInfo = null;
---
Comment #1 by ibuclaw — 2017-06-11T14:47:17Z
One reason to explain it is that the frontend optimizer only runs skin deep. If it were to recursively optimize the expression until it can no longer be simplified, then that should be enough.