digitalmars.D - Bug? A template mixin inside class makes the dtor of class being invoked 3 times
- thesys (34/34) Jul 19 2008 hi,
- Koroskin Denis (3/37) Jul 19 2008 I confirm. Same output for 1.029, 1.031 and 2.017
hi, I got sth wrong with D 1.033. Is there a bug? It's the source code compiled with dmd 1.033 ------------------------------------------------------------------------- extern (C) int printf(char *, ...); class Bar { this() { printf("Bar.this()\n"); } ~this() { printf("Bar.~this()\n"); } mixin Foo; }; template Foo() { } int main(char[][] args) { scope Bar bar = new Bar(); return 0; } -------------------------------------------------------------------- But the output is: -------------------------------------------------------------------- Bar.this() Bar.~this() Bar.~this() Bar.~this() ------------------------------------------------------------------- The dtor of class Bar was invoked 3 times. Why?
Jul 19 2008
On Sat, 19 Jul 2008 18:12:28 +0400, thesys <shaoyoushi gmail.com> wrote:hi, I got sth wrong with D 1.033. Is there a bug? It's the source code compiled with dmd 1.033 ------------------------------------------------------------------------- extern (C) int printf(char *, ...); class Bar { this() { printf("Bar.this()\n"); } ~this() { printf("Bar.~this()\n"); } mixin Foo; }; template Foo() { } int main(char[][] args) { scope Bar bar = new Bar(); return 0; } -------------------------------------------------------------------- But the output is: -------------------------------------------------------------------- Bar.this() Bar.~this() Bar.~this() Bar.~this() ------------------------------------------------------------------- The dtor of class Bar was invoked 3 times. Why?I confirm. Same output for 1.029, 1.031 and 2.017 BTW, scope may be omitted, same result.
Jul 19 2008