Bug 2518 – scope(success) not executed and RAII variable destructor is not called

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2008-12-17T01:20:00Z
Last change time
2014-02-24T15:32:01Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
redsea

Comments

Comment #0 by redsea — 2008-12-17T01:20:11Z
error: scope(success) is not execuated, RAII variable destructor is not called, this bug is critical. I wrote a phobos version test program, and found windows version of dmd is correct, but not linux version. I test dmd 1.038. 1.037, 1.023, all is wrong. the test program is as following: import std.stdio; alias writefln ot; scope class Indent { this() { ot("<<<"); } ~this() { ot(">>>"); } } void doScan(int a) { ot("doScan {{{"); scope(exit) {} scope(failure) ot("doScan failure }}}"); scope(success) ot("doScan ok }}}"); scope auto ident__doScan__ident = new Indent(); if (a == 0 ) return; } void main() { for (int i=0; i<8;i++) doScan(0); } comment the following lines, result would be ok: if (a == 0 ) return; the error output: (copy from linux dmd 1.038, running on debian lenny) [tmp]root ./t doScan {{{ <<< doScan {{{ <<< doScan {{{ <<< doScan {{{ <<< doScan {{{ <<< doScan {{{ <<< doScan {{{ <<< doScan {{{ <<< the correct output (copy from windows dmd 1.038) C:\TEMP>t.exe doScan {{{ <<< >>> doScan ok }}} doScan {{{ <<< >>> doScan ok }}} doScan {{{ <<< >>> doScan ok }}} doScan {{{ <<< >>> doScan ok }}} doScan {{{ <<< >>> doScan ok }}} doScan {{{ <<< >>> doScan ok }}} doScan {{{ <<< >>> doScan ok }}} doScan {{{ <<< >>> doScan ok }}} -------- detail enviorment infomation: [tmp]root uname -a Linux debian-dev-testing 2.6.25.20-pm-mon-02 #1 Sun Dec 7 17:57:03 CST 2008 i686 GNU/Linux [tmp]root dmd -v Digital Mars D Compiler v1.038 Copyright (c) 1999-2008 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/1.0/index.html [tmp]root dmd -v t.d parse t semantic t import object (/root/dmd/bin/../src/phobos/object.d) import std.stdio (/root/dmd/bin/../src/phobos/std/stdio.d) import std.c.stdio (/root/dmd/bin/../src/phobos/std/c/stdio.d) import std.c.stddef (/root/dmd/bin/../src/phobos/std/c/stddef.d) import std.c.stdarg (/root/dmd/bin/../src/phobos/std/c/stdarg.d) import std.format (/root/dmd/bin/../src/phobos/std/format.d) import std.stdarg (/root/dmd/bin/../src/phobos/std/stdarg.d) import std.utf (/root/dmd/bin/../src/phobos/std/utf.d) import std.c.stdlib (/root/dmd/bin/../src/phobos/std/c/stdlib.d) import std.c.string (/root/dmd/bin/../src/phobos/std/c/string.d) import std.string (/root/dmd/bin/../src/phobos/std/string.d) import std.uni (/root/dmd/bin/../src/phobos/std/uni.d) import std.array (/root/dmd/bin/../src/phobos/std/array.d) import std.ctype (/root/dmd/bin/../src/phobos/std/ctype.d) import std.gc (/root/dmd/bin/../src/phobos/std/gc.d) import gcstats (/root/dmd/bin/../src/phobos/gcstats.d) import std.c.linux.linux (/root/dmd/bin/../src/phobos/std/c/linux/linux.d) import std.c.linux.linuxextern (/root/dmd/bin/../src/phobos/std/c/linux/linuxextern.d) import std.c.linux.pthread (/root/dmd/bin/../src/phobos/std/c/linux/pthread.d) import std.intrinsic (/root/dmd/bin/../src/phobos/std/intrinsic.d) semantic2 t semantic3 t code t function this function _dtor function doScan function main gcc t.o -o t -m32 -Xlinker -L/root/dmd/bin/../lib -lphobos -lpthread -lm
Comment #1 by clugdbug — 2009-04-03T07:40:34Z
Fixed DMD2.023 and DMD1.039