www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18412] New: [REG2.077.0] immutable array in library becomes


          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 puremagic.com
          Reporter: ag0aep6g gmail.com

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.

Feb 09 2018