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.
Comment #2 by ibuclaw — 2017-06-11T16:26:14Z
Comment #3 by github-bugzilla — 2017-06-14T22:03:26Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/84e6960563480109ea5d153ae2732e441ba88bd5 fix Issue 17491 - Compiles on invalid: *&s.init.var is not an lvalue https://github.com/dlang/dmd/commit/becedffcf050f7d4b19c97dcd1752cec19d73176 Merge pull request #6893 from ibuclaw/issue17491 fix Issue 17491 - Compiles on invalid: *&s.init.var is not an lvalue
Comment #4 by github-bugzilla — 2017-08-07T13:16:42Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/84e6960563480109ea5d153ae2732e441ba88bd5 fix Issue 17491 - Compiles on invalid: *&s.init.var is not an lvalue https://github.com/dlang/dmd/commit/becedffcf050f7d4b19c97dcd1752cec19d73176 Merge pull request #6893 from ibuclaw/issue17491