[Bug 154] New: invalid code generation on linux with custom allocators/deallocators + 'auto' doubts

Thomas Kuehne thomas-dloop at kuehne.cn
Wed May 24 09:31:00 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail at puremagic.com schrieb am 2006-05-23:
> The following code:
>
>
> tmp3.d:
> ----
>
> import std.c.stdlib;
>
> class Foo
> {
>     new (size_t sz)
>     {
>         return std.c.stdlib.malloc(sz);
>     }
>
>     delete(void* p)
>     {
>         if (p) std.c.stdlib.free(p);
>     }
> }
>
> void main() {
>     Foo f = new Foo;
>     delete f;
> }
>
> ----
>
> doesn't seem to like linux at all...
>
>
> h3 at h3:~/coding> dmd tmp3.d
> gcc tmp3.o -o tmp3 -lphobos -lpthread -lm
> h3 at h3:~/coding> ./tmp3
> Illegal instruction
> h3 at h3:~/coding> gdb tmp3
> GNU gdb 6.3
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain
> conditions.Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i586-suse-linux"...Using host libthread_db library
> "/lib/tls/libthread_db.so.1".
>
> (gdb) r
> Starting program: /home/h3/coding/tmp3
> [Thread debugging using libthread_db enabled]
> [New Thread 1075353280 (LWP 22608)]
>
> Program received signal SIGILL, Illegal instruction.
> [Switching to Thread 1075353280 (LWP 22608)]
> 0x0805c474 in _Class_8TypeInfo ()
> (gdb) bt
> #0  0x0805c474 in _Class_8TypeInfo ()
> #1  0x0804fc59 in _d_callfinalizer ()
> #2  0x0804fa16 in _d_delclass ()
> #3  0x0804a127 in _Dmain ()
> #4  0x0804af03 in main ()
>
>
> Adding an empty constructor ("this() {}") to the Foo class fixes the problem.
> It's also been reported that it runs fine on Windows.

Added to DStress as
http://dstress.kuehne.cn/run/d/delete_14_A.d
http://dstress.kuehne.cn/run/d/delete_14_B.d

see also:
http://dstress.kuehne.cn/run/d/delete_12_A.d
http://dstress.kuehne.cn/run/d/delete_12_B.d
http://dstress.kuehne.cn/run/d/delete_12_C.d
http://dstress.kuehne.cn/run/d/delete_12_D.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFEdD7H3w+/yD4P9tIRAjrGAJ9C1IglWAxit5L7a/DTdsqWgWZulACdHZou
Fwg0p8uuRF0+QAvHOTRyET0=
=FDF+
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list