Thread overview
[Issue 15408] S.init for struct containing member field with array literal initializer fails @nogc
Dec 17, 2022
Iain Buclaw
August 03, 2022
https://issues.dlang.org/show_bug.cgi?id=15408

Steven Schveighoffer <schveiguy@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec, wrong-code
                 CC|                            |schveiguy@gmail.com
                 OS|Mac OS X                    |All
           Severity|normal                      |major

--- Comment #1 from Steven Schveighoffer <schveiguy@gmail.com> ---
This reduces in AST to:

```d
S s = S([42]);
```

Which is why it always allocates.

This also defies the spec, which states:

> .init produces a constant expression that is the default initializer.

This is not a constant expression.

This also leads to such puzzles as `assert(S.init !is S.init)`

Also note that:

```d
S s;
```

Does *not* produce an allocation.

S.init should not allocate. Neither should S()

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15408

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
December 13
https://issues.dlang.org/show_bug.cgi?id=15408

--- Comment #2 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19074

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--