Bug 15694 – Initializing static array member of a type that has @disabled default constructor

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-02-17T08:49:48Z
Last change time
2024-12-13T18:46:56Z
Assigned to
No Owner
Creator
Ali Cehreli
Moved to GitHub: dmd#19099 →

Comments

Comment #0 by acehreli — 2016-02-17T08:49:48Z
Related newsgroup thread: http://forum.dlang.org/thread/[email protected]?page=1 The following constructor fails compilation in a way that suggests some error in the order members are initialized. import std.stdio; struct Foo { int i; /* This line is pertinent: */ @disable this(); this(int i) { this.i = i; } } struct FooList { Foo[3] foos; this(int) { /* This constructor fails compilation with dmd 2.070.0: * * Error: field 'foos' initialization is not allowed in loops or * after labels * * There are at least two interesting ways of passing compilation: * * a) Either add the following line BEFORE the loop: * foos[0] = Foo(10); * * b) Or remove 'ref' in the loop AND add the following line AFTER * the loop: * foos[0] = Foo(10); */ foreach (ref f; foos[]) { writeln(f.i); } } } void main() { } Ali
Comment #1 by robert.schadek — 2024-12-13T18:46:56Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19099 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB