Bug 8193 – wrong error message on escaping initialized immutable instance field

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-03T10:33:00Z
Last change time
2012-12-27T17:23:46Z
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2012-06-03T10:33:47Z
DMD 2.059/2.060head: struct A{ immutable int z=2; auto foo(){return &z;} } Error: escaping reference to local z Either z should not be accessible at all or the code should compile.
Comment #1 by andrej.mitrovich — 2012-12-27T17:23:46Z
Unfortunately this is another case of Issue 3449. If you remove the initualizer it will work (not also the .sizeof property of the struct when using/not using initializers for const/immutable fields). *** This issue has been marked as a duplicate of issue 3449 ***