Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 16, 2010 [Issue 4328] New: templated unittests fail to link when instantiated from other file if compiler order isn't correct | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4328 Summary: templated unittests fail to link when instantiated from other file if compiler order isn't correct Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: schveiguy@yahoo.com --- Comment #0 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-06-16 06:46:44 PDT --- testunittest.d: struct S(T) { unittest { assert(0); } } testunittestmain.d: import testunittest; void main() { S!int s; } When compiled this way: dmd -unittest testunittest.d testunittestmain.d The following error occurs: testunittest.o: In function `_D12testunittest8__T1STiZ1S11__unittest3FZv': testunittestmain.d:(.text._D12testunittest8__T1STiZ1S11__unittest3FZv+0x9): undefined reference to `_D12testunittest15__unittest_failFiZv' collect2: ld returned 1 exit status If I compile this way: dmd -unittest testunittestmain.d testunittest.d The compiler generally has no problem with order of files for linking, I would expect the same here. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 27, 2010 [Issue 4328] templated unittests fail to link when instantiated from other file if compiler order isn't correct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=4328 Rainer Schuetze <r.sagitario@gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |r.sagitario@gmx.de --- Comment #1 from Rainer Schuetze <r.sagitario@gmx.de> 2010-08-27 08:15:20 PDT --- even worse: the link fails if the template is in a library and the library is not compiled with unittests: import std.stdio; void main() { writef("\n"); } dmd -unittest test.d OPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D3std6format15__unittest_failFiZv --- errorlevel 1 Strangely, the relased phobos.lib is compiled with unittests, while the makefile does not pass "-unittest". So this does only show up when I compile the runtime library myself. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 27, 2010 [Issue 4328] templated unittests fail to link when instantiated from other file if compiler order isn't correct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=4328 --- Comment #2 from Rainer Schuetze <r.sagitario@gmx.de> 2010-08-27 08:39:32 PDT --- Here's a workaround: similar to the assert handling, generate the unittest_fail function whenever there is a template in the module: Index: template.c =================================================================== --- template.c (revision 632) +++ template.c (working copy) @@ -429,6 +429,13 @@ sc->module->toModuleAssert(); } + if (/*global.params.useUnitTests &&*/ sc->module) + { + // Generate this function as it may be used + // when template is instantiated in other modules + sc->module->toModuleUnittest(); + } + /* Remember Scope for later instantiations, but make * a copy since attributes can change. */ -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 07, 2011 [Issue 4328] templated unittests fail to link when instantiated from other file if compiler order isn't correct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=4328 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-02-06 23:52:53 PST --- https://github.com/D-Programming-Language/dmd/commit/76038f0813c514c2690d4e01ea7ff3aed0434ea4 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation