[Issue 18412] New: [REG2.077.0] immutable array in library becomes null when referenced in static constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 9 23:27:15 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18412
Issue ID: 18412
Summary: [REG2.077.0] immutable array in library becomes null
when referenced in static constructor
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Keywords: wrong-code
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ag0aep6g at gmail.com
Spin-off from issue 18403.
m1.d:
----
import m2: f;
void main() { f(); }
----
m2.d:
----
static this()
{
auto k = keywords;
}
immutable int[] keywords = [42];
void f()
{
assert(keywords.ptr !is null); /* fails; should pass */
}
----
Compile and run (Windows via Wine, DMD32 D Compiler v2.077.0):
----
dmd -lib m2.d
dmd m1.d m2.lib
./m1.exe
----
Works with 2.076.1. Works on Linux. Works when the array is mutable. Works when
the array is declared before the static constructor.
--
More information about the Digitalmars-d-bugs
mailing list