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 ?
000000000043050c <_Dmain>:
43050c: push %rbp
43050d: mov %rsp,%rbp
430510: sub $0x40,%rsp
430514: movabs $0x3ff0000000000000,%rax
43051b:
43051e: mov %rax,-0x40(%rbp)
430522: movsd -0x40(%rbp),%xmm0
430527: rex.W movsd %xmm0,-0x30(%rbp)
43052d: xor %edx,%edx
43052f: mov %rax,-0x10(%rbp)
430533: mov %rdx,-0x8(%rbp)
430537: mov %rax,-0x28(%rbp)
43053b: mov %rdx,-0x20(%rbp)
43053f: mov 0x28022(%rip),%rdx
430546: mov 0x28013(%rip),%rsi
What are these ? What are they referering to
My guess is they are refering to length and
ptr for "%x" string literal, which is passed to writefln.
43054d: mov -0x28(%rbp),%rdi
430551: callq 430874 <void
std.stdio.writefln!(immutable(char)[],
ulong).writefln(immutable(char)[], ulong)>
430556: xor %eax,%eax
430558: leaveq
430559: retq
This calls writefln, this is not what your code does just
above. Are you sure you are posting the right assembly ? Do
you use the inline flag ?
I think you are confusing my post with some other post (I am not
OP).
OK, my mistake.
My code sample was:
import std.stdio;
struct Y {
int[] _data;
}
struct CFS {
double x;
Y growth;
}
void main() {
auto s = CFS(1.0);
writefln("%x", s.growth._data.length); // prints
3ff0000000000000
}
The constructor's argument was 2.0 in my previous sample, but it
should have been 1.0.
I'm not sure what DMD is trying to do, but the function call to
writefln is clearly wrong.