Comment #0 by snarwin+bugzilla — 2023-11-02T15:20:22Z
As of DMD 2.105.3, the following program asserts at runtime:
---
void main()
{
int n;
struct Nested
{
int fun() { return n; }
}
static a = Nested.init;
auto b = Nested.init;
assert(a is b); // ok
static a1 = (Nested[1]).init;
auto b1 = (Nested[1]).init;
assert(a1[0] is b1[0]); // fails
}
---
The error message, with -checkaction=context, is:
---
[email protected](15): Nested(<context>: 0x0) !is Nested(<context>: 0x7f8e09158000)
---
A variable initialized with Nested.init will always have a null context pointer, whether it is initialized at compile time or runtime. However, a variable initialized with (Nested[1]).init has a null context pointer when initialized at compile time, and a non-null context pointer when initialized at runtime.
For the sake of consistency, the context pointer should be null in all cases.
Comment #1 by robert.schadek — 2024-12-13T19:31:31Z