Bug 16043 – Wrong line number for closure in -vgc

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-18T14:37:22Z
Last change time
2024-12-13T18:47:49Z
Assigned to
No Owner
Creator
Mathias Lang
Moved to GitHub: dmd#19125 →

Comments

Comment #0 by mathias.lang — 2016-05-18T14:37:22Z
The following code: ``` void test () // L1 { string[] foo; auto f = () { assert(foo[0] == "HellO"); }; // L4 foo ~= "HellO"; // L5 } ``` Compiled with `dmd -c -vgc test.d` gives the following output: ``` test.d(5): vgc: operator ~= may cause GC allocation test.d(1): vgc: using closure causes GC allocation ``` So the appending has the right line, but not the closure allocation.
Comment #1 by k.hara.pg — 2016-05-18T16:18:44Z
The shown line number is not wrong. The closure environment that is closing variable foo, is allocated at the start of function test() == line 1. The delegate literal at line 4 just refers it. So, the issue would be: 1. the message text that is not enough helpful (diagnostic), or 2. lack of information about the location where the closed variable 'foo' is used from (enhancement).
Comment #2 by robert.schadek — 2024-12-13T18:47:49Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19125 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB