Bug 15192 – DIP25: Nested ref returns are type checked unsoundly

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-12T10:43:00Z
Last change time
2016-10-01T11:48:07Z
Keywords
pull, safe
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2015-10-12T10:43:19Z
The following code corrupts memory: enum N=100; ref int[N] fun(ref int[N] x)@safe{ ref int[N] bar(){ return x; } return bar(); } ref int[N] hun()@safe{ int[N] k; return fun(k); } void bang(ref int[N] x)@safe{ x[]=0x25BAD; } void main()@safe{ bang(hun); }
Comment #1 by bugzilla — 2016-06-30T06:23:52Z
Simplified: ref int fun(ref int x) @safe { ref int bar(){ return x; } return bar(); } This is a failure to detect that parameter x should be marked as 'return ref', not just 'ref'.
Comment #2 by bugzilla — 2016-06-30T07:08:40Z
Comment #3 by github-bugzilla — 2016-07-01T07:27:22Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/ad419f24f498526e112f07bf9fbe26e31de319bc fix Issue 15192 - DIP25: Nested ref returns are type checked unsoundly https://github.com/dlang/dmd/commit/feb06a7548341ab1d794061d66850c611a7fb074 Merge pull request #5893 from WalterBright/fix15192 fix Issue 15192 - DIP25: Nested ref returns are type checked unsoundly
Comment #4 by github-bugzilla — 2016-10-01T11:48:07Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/ad419f24f498526e112f07bf9fbe26e31de319bc fix Issue 15192 - DIP25: Nested ref returns are type checked unsoundly https://github.com/dlang/dmd/commit/feb06a7548341ab1d794061d66850c611a7fb074 Merge pull request #5893 from WalterBright/fix15192