digitalmars.D.bugs - [Issue 15956] New: Incorrect value inside enum using simd vectors,
- via Digitalmars-d-bugs (60/60) Apr 25 2016 https://issues.dlang.org/show_bug.cgi?id=15956
https://issues.dlang.org/show_bug.cgi?id=15956 Issue ID: 15956 Summary: Incorrect value inside enum using simd vectors, weird tym errors, and weird if(true) {} partial solution. Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: lasssafin gmail.com Consider this piece of code: import std.stdio : writeln; struct vec4 { import core.simd; string toString() const { import std.format : format; return "%s\t%s\t%s\t%s".format(vec.array[0], vec.array[1], vec.array[2], vec.array[3]); } float4 vec; this(in float[4] arr) { vec.array = arr; } // Switching the constructor out with this removes the if(true) error and corrects the value inside the enum. /+ this(in float4 arr) { vec = arr; } +/ } void main(string[] _ARGS) { enum vec4 enm = [1, 0.4, 0.6, 1]; enm.writeln; vec4 rntime = [1, 0.4, 0.6, 1]; rntime.writeln; // When uncommented causes error: incompatible types for ((rntime.vec) == (vec4([1.00000F, 0.4F, 0.6F, 1.00000F]).vec)): '__vector(float[4])' and '__vector(float[4])' // writeln(rntime == enm); Comparing only vec explicitly doesn't work either. // When commented causes error: // tym = x1d // Internal error: backend/cgxmm.c 547 if(true) {} // Condition can really be anything. } Output: 1 0 0 0 // enm 1 0.4 0.6 1 // rntime Output with -O: 1 0.4 0.6 1 // enm 1 0.4 0.6 1 // rntime As you can see, the value inside the enum is not the value one would expect there to be. There is also the error in comparing the two struct and the weird if(true) clause. --
Apr 25 2016