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

Spin-off from issue 18403.

import m2: f;
void main() { f(); }

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

Works with 2.076.1. Works on Linux. Works when the array is mutable. Works when
the array is declared before the static constructor.


Reply via email to