The debug info for this program is a little strange: --------- //import std.stdio; //import std.base64; void main() {} unittest { int* a = null; *a = 10; } --------- If both imports are commented the modtest function doesn't show up in stack traces at all. If std.stdio is imported: 0x405cd2 test2._D5test29__modtestFZv /opt/gdc/include/d/4.8.1/std/conv.d:104 If std.base64 is imported instead: 0x405d52 test2._D5test29__modtestFZv /opt/gdc/include/d/4.8.1/std/format.d:1211 Probably produces similar results when importing any other random module as well.
A test for you that doesn't require importing modules: --- void main() {} unittest { int* a = null; *a = 10; } unittest { int* a = null; *a = 10; } --- See comment in d-objfile.cc(build_call_function): // If there is only one function, just return that.
Found it. The DECL line number is actually correct, but we build the function body outside of the ::toIR functions and therefore set_input_location / doLineNote is not updated correctly.
https://github.com/D-Programming-GDC/GDC/commit/a63691f05dd8c96be4da1359da71ca18fc97e355