Bug 15664 – [REG2.064] incorrect initialisation of member of an immutable struct
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-02-09T15:13:00Z
Last change time
2016-03-11T01:57:20Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
abulmo
Comments
Comment #0 by abulmo — 2016-02-09T15:13:47Z
[code]
import std.stdio;
struct Data
{
int a[2];
int b[2][2];
int c;
};
immutable Data d = {[ 1, 2], [[ 3, 4], [5, 6]], 7};
unittest
{
assert(d.c == 7);
}
void main()
{
writeln(d);
}
[/code]
Compiled with dmd x86_64 (version 2.62.2 & 2.70.0) on linux (fedora), it gives the incorrect following output:
immutable(Data)([1, 2], [[3, 4], [5, 6]], 3)
the expected output is:
immutable(Data)([1, 2], [[3, 4], [5, 6]], 7)
Optimization compilation flags does not have any impact on the output.
The -unittest flag triggers the assert.