Re: is this an instance of the 16-byte struct bug

2013-11-05 Thread John Colvin
On Monday, 4 November 2013 at 22:09:45 UTC, jerro wrote: void main() { auto s = CFS(1.0); // crash //auto s = CFS(1, Y()); // crash //auto s = CFS(1, Y([])); // works writeln(s); } What do you mean by crash ? It's segfaults. It doesn't happen if you change 1.0 literal to some other

Re: is this an instance of the 16-byte struct bug

2013-11-05 Thread John Colvin
On Tuesday, 5 November 2013 at 09:34:47 UTC, John Colvin wrote: On Monday, 4 November 2013 at 22:09:45 UTC, jerro wrote: void main() { auto s = CFS(1.0); // crash //auto s = CFS(1, Y()); // crash //auto s = CFS(1, Y([])); // works writeln(s); } What do you mean by crash ? It's

Re: is this an instance of the 16-byte struct bug

2013-11-05 Thread Daniel Davidson
On Tuesday, 5 November 2013 at 09:34:47 UTC, John Colvin wrote: Can't reproduce on Git master x86_64 linux. Prints 0 no matter what flags are used. Mac - OS X 10.9 (13A603) dmd -v DMD64 D Compiler v2.064 Copyright (c) 1999-2013 by Digital Mars written by Walter Bright bash-3.2$ rdmd

Re: is this an instance of the 16-byte struct bug

2013-11-05 Thread Daniel Davidson
On Tuesday, 5 November 2013 at 00:16:11 UTC, deadalnix wrote: I'm not sure what DMD is trying to do, but the function call to writefln is clearly wrong. Strange bug. FWIW adding a constructor `this(immutable(int)[] data) { _data = data; }` seems to be a workaround. Thanks Dan

Re: is this an instance of the 16-byte struct bug

2013-11-05 Thread Daniel Davidson
On Tuesday, 5 November 2013 at 00:16:11 UTC, deadalnix wrote: I'm not sure what DMD is trying to do, but the function call to writefln is clearly wrong. Strange bug. FWIW adding a constructor `this(immutable(int)[] data) { _data = data; }` seems to be a workaround. Thanks Dan

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread Daniel Davidson
Ok - pretty sure this is not related to 16-byte structs, since if I just remove one of the fields it still crashes. I opened an issue - and here is a simplified version: http://d.puremagic.com/issues/show_bug.cgi?id=11440 import std.stdio; struct Y { private immutable(int)[] _data; }

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread deadalnix
On Monday, 4 November 2013 at 19:24:11 UTC, Daniel Davidson wrote: Ok - pretty sure this is not related to 16-byte structs, since if I just remove one of the fields it still crashes. I opened an issue - and here is a simplified version: http://d.puremagic.com/issues/show_bug.cgi?id=11440

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread jerro
void main() { auto s = CFS(1.0); // crash //auto s = CFS(1, Y()); // crash //auto s = CFS(1, Y([])); // works writeln(s); } What do you mean by crash ? It's segfaults. It doesn't happen if you change 1.0 literal to some other value, say 2.0. It's a truly bizarre bug. Here's a

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread jerro
It doesn't happen with -O, or when compiled with LDC or GDC. And it doesn't happen when building with -m32 (I'm on x86_64 linux).

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread deadalnix
OK. Now usual question to try to understand what is going wrong. Can you try on 32/64 bits ? Also, what happen with GDC and LDC ?

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread jerro
On Monday, 4 November 2013 at 22:27:39 UTC, deadalnix wrote: OK. Now usual question to try to understand what is going wrong. Can you try on 32/64 bits ? Also, what happen with GDC and LDC ? The code I posted above prints 3ff0 when built with dmd on x86_64 without any flags. It

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread deadalnix
On Monday, 4 November 2013 at 22:42:35 UTC, jerro wrote: On Monday, 4 November 2013 at 22:27:39 UTC, deadalnix wrote: OK. Now usual question to try to understand what is going wrong. Can you try on 32/64 bits ? Also, what happen with GDC and LDC ? The code I posted above prints

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread jerro
Then it look like a dmd backend bug. Can you post the generated assembly ? 0043050c _Dmain: 43050c: push %rbp 43050d: mov%rsp,%rbp 430510: sub$0x40,%rsp 430514: movabs $0x3ff0,%rax 43051b: 43051e: mov

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread deadalnix
On Monday, 4 November 2013 at 22:56:48 UTC, jerro wrote: Then it look like a dmd backend bug. Can you post the generated assembly ? 0043050c _Dmain: 43050c: push %rbp 43050d: mov%rsp,%rbp 430510: sub$0x40,%rsp 430514: movabs

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread jerro
On Monday, 4 November 2013 at 23:07:27 UTC, deadalnix wrote: On Monday, 4 November 2013 at 22:56:48 UTC, jerro wrote: Then it look like a dmd backend bug. Can you post the generated assembly ? 0043050c _Dmain: 43050c: push %rbp 43050d: mov%rsp,%rbp 430510:

Re: is this an instance of the 16-byte struct bug

2013-11-04 Thread deadalnix
On Monday, 4 November 2013 at 23:14:08 UTC, jerro wrote: On Monday, 4 November 2013 at 23:07:27 UTC, deadalnix wrote: On Monday, 4 November 2013 at 22:56:48 UTC, jerro wrote: Then it look like a dmd backend bug. Can you post the generated assembly ? 0043050c _Dmain: 43050c:

is this an instance of the 16-byte struct bug

2013-11-02 Thread Daniel Davidson
and what is the 16 byte struct bug? http://forum.dlang.org/post/nqqujtblyvxvtrlsb...@forum.dlang.org import std.datetime; import std.range; import std.stdio; struct DateRate { Date date; double value = 0.0; } struct RateCurve { private immutable(DateRate)[] _data; } struct CFS {