Comment #0 by jcrapuchettes — 2014-01-30T13:40:00Z
The following code example was tested with 2.063.2 and executes without error. If compiled with 2.064.2 or 2.065.0-b2, the example compiles, but segfaults when run.
In the example, commenting or changing most of the lines will allow 2.064.2+ to produce code that does not segfault.
Backtrace output from gdb at point of segfault:
----------------
(gdb) bt
#0 0x000000000042d9eb in _d_arrayliteralTX ()
#1 0x0000000000429dcd in valid_sparse.main() (this=0x0) at valid_sparse.d:32
#2 0x000000000042a57f in valid_sparse.Test.__T8opBinaryVAyaa2_696eZ.opBinary() (this=0x7fffffffdad8, fun=...) at valid_sparse.d:42
#3 0x0000000000429da2 in D main () at valid_sparse.d:26
#4 0x000000000042cf20 in rt.dmain2._d_run_main() ()
#5 0x000000000042ce7a in rt.dmain2._d_run_main() ()
#6 0x000000000042cee0 in rt.dmain2._d_run_main() ()
#7 0x000000000042ce7a in rt.dmain2._d_run_main() ()
#8 0x000000000042cdfb in _d_run_main ()
#9 0x000000000042ae25 in main ()
Example:
----------------
import std.array;
import std.traits;
import std.algorithm;
struct BasicNode(T) { T id; }
struct Hierarchy(Code)
{
struct Node { Code id; }
Node[] allNodes;
bool opEquals(OtherH)(OtherH )
{
allNodes.map!("a.id").array;
}
}
struct Test
{
void opBinary(string op)(void delegate() fun)
{
fun();
}
}
void main()
{
Test() in
{
enum BlaEnum : ubyte { All }
auto Blas = [EnumMembers!BlaEnum].map!(a => BasicNode!BlaEnum(a));
Hierarchy!(BlaEnum) H_T;
};
}
Comment #1 by dlang-bugzilla — 2014-01-30T18:45:14Z
On Win32, it compiles and runs. On Win64 there is a linker error (duplicate COMDAT).
Comment #2 by dlang-bugzilla — 2014-01-30T19:02:24Z
Comment #3 by dlang-bugzilla — 2014-02-04T13:14:56Z
I reran the bisection on Linux/64, where I could reproduce the original problem. But the bisection identified the same change as the regression:
https://github.com/D-Programming-Language/phobos/pull/1305
I'll try to reduce away the Phobos dependency.
Comment #4 by dlang-bugzilla — 2014-02-04T15:00:09Z
Reduced test case:
//////////////////////////////////////////
struct S(T)
{
void f()()
{
new T[1];
}
bool opEquals(O)(O)
{
f();
}
}
void main()
{
()
{
enum E { e }
auto arr = [E.e];
S!E s;
}
();
}
//////////////////////////////////////////
On Win64, this produces the error:
test.exe.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT '_D45TypeInfo_AE4test4mainFZv9__lambda1FNaNbNfZv1E6__initZ'
As I suspected, the Phobos change only uncovered a compiler problem.