[Issue 15664] New: incorrect initialisation of member of an immutable struct
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Feb 9 07:13:47 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15664
Issue ID: 15664
Summary: incorrect initialisation of member of an immutable
struct
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: abulmo at club-internet.fr
[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.
--
More information about the Digitalmars-d-bugs
mailing list