Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 09, 2006 [Issue 668] New: Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=668 Summary: Use of *.di files breaks the order of static module construction Product: D Version: 0.176 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: kinaba@is.s.u-tokyo.ac.jp The spec says that "each module is assumed to depend on any imported modules being statically constructed first" in module.html. But when I use *.di interface files, the order seems broken. Here is an example: //credit goes to http://pc8.2ch.net/test/read.cgi/tech/1158013550/987 ------- lib.d ------- bool initialized; static this(){ initialized = true; } ------- main.d ------- import lib; import std.stdio; void main(){ } static this(){ writefln("lib.initialized? ", lib.initialized); } > dmd -c -H lib.d // generating lib.di > dmd main.d lib.obj > main lib.initialized? false // wrong > del lib.di // deleteing b.di > dmd main.d lib.obj > main lib.initialized? true // correct -- |
December 10, 2006 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 fvbommel@wxs.nl changed: What |Removed |Added ---------------------------------------------------------------------------- OS/Version|Windows |All Version|0.176 |0.177 ------- Comment #1 from fvbommel@wxs.nl 2006-12-10 04:49 ------- The likely cause: ----- urxae@localhost:~/tmp$ cat lib.d bool initialized; static this(){ initialized = true; } urxae@localhost:~/tmp$ dmd -H -c lib.d urxae@localhost:~/tmp$ cat lib.di // D import file generated from 'lib.d' bool initialized; ----- The static constructor isn't present in the .di so the compiler doesn't see it when compiling main.d. Confirmed on dmd-0.177/Linux. -- |
April 25, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 kamm@incasoftware.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kamm@incasoftware.de ------- Comment #2 from kamm@incasoftware.de 2007-04-25 02:20 ------- Indeed, when you change lib.di to show the existance of a static constructor: lib.di --- // D import file generated from 'lib.d' bool initialized; static this(); --- Then it'll work as expected. Confirmed on dmd 1.013. -- |
June 19, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 sean@f4.ca changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sean@f4.ca ------- Comment #3 from sean@f4.ca 2007-06-18 22:20 ------- *** Bug 1278 has been marked as a duplicate of this bug. *** -- |
July 04, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 clayasaurus@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clayasaurus@gmail.com ------- Comment #4 from clayasaurus@gmail.com 2007-07-03 20:45 ------- This bug is blocking the Arc v.2 release. -- |
July 04, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 deewiant@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |blocker ------- Comment #5 from deewiant@gmail.com 2007-07-04 01:28 ------- Raising severity in accordance with clayasaurus's comment. -- |
July 04, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 ------- Comment #6 from braddr@puremagic.com 2007-07-04 01:51 ------- Strictly speaking, since there's a work around, it's not a blocker. But it's fairly serious so I'll leave it as is. -- |
July 17, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 ------- Comment #7 from clayasaurus@gmail.com 2007-07-16 23:18 ------- I'm using a work-around for now and I am going to release Arc v.2, but I still want this bug fixed! :) Plus, this bug is high-severity for any DSSS installable software, because any DSSS library that uses static ctors will be broken. -- |
July 23, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 kamm@incasoftware.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #8 from kamm@incasoftware.de 2007-07-23 02:31 ------- Fixed in DMD 1.019 and 2.003. Thanks Walter! -- |
August 06, 2007 [Issue 668] Use of *.di files breaks the order of static module construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=668 sean@f4.ca changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | ------- Comment #9 from sean@f4.ca 2007-08-06 18:14 ------- I don't think this issue is completely resolved. The compiler now generates a "static this() {}" in the .di file whenever it seems a static ctor in the module. However, the presence of a complete but empty static ctor seems to convince the compiler that they are available, inlinable and empty. In some instances, this causes errors like: "filename.di(0): variable SOME_VARIABLE missing initializer in static constructor for const variable" This is preventing the Tango user library from compiling properly on 1.019 and above for Linux/MacOS. The solution seems to be generating "static this();" rather than the complete "static this() {}". -- |
Copyright © 1999-2021 by the D Language Foundation