Bug 8914 – Wrong `escaping reference` error on returning static array

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-30T07:09:52Z
Last change time
2024-12-13T18:02:10Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Denis Shelomovskii
See also
https://issues.dlang.org/show_bug.cgi?id=17076
Moved to GitHub: dmd#18481 →

Comments

Comment #0 by verylonglogin.reg — 2012-10-30T07:09:52Z
As static array is a value type, there should be no error: --- int[2] f(int[2] arr...) { return arr; } // Error: escaping reference to variadic parameter arr ---
Comment #1 by john.loughran.colvin — 2015-05-24T19:12:39Z
This is still happening. Workaround is to create a temporary and hope the compiler elides it.
Comment #2 by dlang-bugzilla — 2017-07-21T05:12:13Z
Test case above no longer fails to compile since 2.074.0 (https://github.com/dlang/dmd/pull/6420), however, adding an indirection to the parameter type still shows the error: int*[2] f(int*[2] arr...) { return arr; } // Error: returning `arr` escapes a reference to variadic parameter `arr`
Comment #3 by robert.schadek — 2024-12-13T18:02:10Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18481 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB