Re: Weird array setting behaviour on Windows(-m64)

2016-04-13 Thread ref2401 via Digitalmars-d-learn
On Wednesday, 13 April 2016 at 15:07:09 UTC, rikki cattermole 
wrote:



Verified that it is a codegen problem for Win64 and not *nix.
Please file a bug report.


https://issues.dlang.org/show_bug.cgi?id=15921
Done, Thanks



Re: Weird array setting behaviour on Windows(-m64)

2016-04-13 Thread rikki cattermole via Digitalmars-d-learn

On 14/04/2016 2:49 AM, ref2401 wrote:

Hello,

I got stuck with a weird array setting behaviour and I need help. Just
have a look at the example.

OS: Win 8.1 Pro
DMD: v2.071.0
Build-cmd: dmd main.d -ofconsole-app.exe -debug -unittest -g -wi -m64

module dmain;
import std.stdio;

struct Vec {
 float a;
}

void main(string[] args) {
 Vec[] array = new Vec[4];

 writeln("before: ", array); //  prints [Vec(nan), Vec(nan),
Vec(nan), Vec(nan)]

 array[] = Vec(24);

 writeln("after: ", array); // prints [Vec(0), Vec(0), Vec(0), Vec(0)]
}

Seems like slicing is broken in general. All the following variations
produce different results but they are all wrong.
array[] = Vec(24);
array[0 .. 1] = Vec(24);
array[0 .. $] = Vec(24);

It works as expected if I do one of the following things:
1. Get rid of -m64. If I compile with -m32 flag then I cannot replicate
the issue.

2. Changing the type of the Vec.a field from float to real, int, uint,
long, ulong fixes the issue. Double still causes the issues.

3. Adding new fields to the Vec struct.

3.1. Vec {float a, b; } still does not work but the result is slightly
different.
array[] = Vec(24, 5);
writeln("after: ", array); // [Vec(5, 0), Vec(5, 0), Vec(5, 0), Vec(5, 0)]

3.2. Vec { float a, b, c; } works fine.

4. Using index operator: array[0] = Vec(24) works fine


Verified that it is a codegen problem for Win64 and not *nix.
Please file a bug report.


Weird array setting behaviour on Windows(-m64)

2016-04-13 Thread ref2401 via Digitalmars-d-learn

Hello,

I got stuck with a weird array setting behaviour and I need help. 
Just have a look at the example.


OS: Win 8.1 Pro
DMD: v2.071.0
Build-cmd: dmd main.d -ofconsole-app.exe -debug -unittest -g -wi 
-m64


module dmain;
import std.stdio;

struct Vec {
float a;
}

void main(string[] args) {
Vec[] array = new Vec[4];

	writeln("before: ", array); //  prints [Vec(nan), Vec(nan), 
Vec(nan), Vec(nan)]


array[] = Vec(24);

	writeln("after: ", array); // prints [Vec(0), Vec(0), Vec(0), 
Vec(0)]

}

Seems like slicing is broken in general. All the following 
variations produce different results but they are all wrong.

array[] = Vec(24);
array[0 .. 1] = Vec(24);
array[0 .. $] = Vec(24);

It works as expected if I do one of the following things:
1. Get rid of -m64. If I compile with -m32 flag then I cannot 
replicate the issue.


2. Changing the type of the Vec.a field from float to real, int, 
uint, long, ulong fixes the issue. Double still causes the issues.


3. Adding new fields to the Vec struct.

3.1. Vec {float a, b; } still does not work but the result is 
slightly different.

array[] = Vec(24, 5);
writeln("after: ", array); // [Vec(5, 0), Vec(5, 0), Vec(5, 0), 
Vec(5, 0)]


3.2. Vec { float a, b, c; } works fine.

4. Using index operator: array[0] = Vec(24) works fine