www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - DMD 0.97: crash with struct sorting

reply k2 <k2_member pathlink.com> writes:
DMD 0.97: crash with struct sorting

This code causes DMD 0.97 to segfault:

struct Foo {

int opCmp(Foo f)
{
return 0;
}
}

int main(char[][] args)
{
Foo[] foo;

foo.sort;

return 0;
}

---
w2000 DMD 0.97
Aug 04 2004
next sibling parent reply Arcane Jill <Arcane_member pathlink.com> writes:
In article <ceq9g7$25mj$1 digitaldaemon.com>, k2 says...
DMD 0.97: crash with struct sorting

This code causes DMD 0.97 to segfault:

struct Foo {

int opCmp(Foo f)
{
return 0;
}
}

int main(char[][] args)
{
Foo[] foo;

foo.sort;

return 0;
}

---
w2000 DMD 0.97

Presumably Foo.sizeof is zero, which I imagine would cause problems for sort? Jill
Aug 04 2004
parent Nick <Nick_member pathlink.com> writes:
In article <cerbqk$cus$1 digitaldaemon.com>, Arcane Jill says...
Presumably Foo.sizeof is zero, which I imagine would cause problems for sort?

Jill

It's the compiler that crashes, not the program. (A simple test also comfirms that .sort doesn't mind empty arrays.) Nick
Aug 04 2004
prev sibling parent reply Juanjo =?ISO-8859-15?Q?=C1lvarez?= <juanjuxNO SPAMyahoo.es> writes:
k2 wrote:

 DMD 0.97: crash with struct sorting
 
 This code causes DMD 0.97 to segfault:
 
 struct Foo {
 
 int opCmp(Foo f)
 {
 return 0;
 }
 }
 
 int main(char[][] args)
 {
 Foo[] foo;
 
 foo.sort;
 
 return 0;
 }

Seems to work on Linux.
Aug 04 2004
parent Nick <Nick_member pathlink.com> writes:
In article <cers5l$m3a$1 digitaldaemon.com>, Juanjo =?ISO-8859-15?Q?=C1lvarez?=
says...
Seems to work on Linux.

I get a segfault on Linux, haven't tried Windows (but it should be the same.) Since k2 used the word "segfault" I assume that was on Linux as well. Nick
Aug 05 2004