is this an instance of the 16-byte struct bug

jerro a at a.com
Mon Nov 4 14:09:45 PST 2013


>> 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 slightly simplified case:

import std.stdio;

struct Y {
      int[] _data;
}

struct CFS {
      double x;
      Y growth;
}

void main() {
      auto s = CFS(2.0);
      writefln("%x", s.growth._data.length); // prints
3ff0000000000000
}

It doesn't happen with -O, or when compiled with LDC or GDC.


More information about the Digitalmars-d mailing list