diff --git a/src/glue.c b/src/glue.c index d72ccf97891f..c93f2e8902e7 100644 --- a/src/glue.c +++ b/src/glue.c @@ -603,6 +603,12 @@ void FuncDeclaration::toObjFile(int multiobj) TemplateInstance *ti = inTemplateInstance(); if (!global.params.useUnitTests && !global.params.allInst && + /* The issue is that if the importee is compiled with a different -debug + * setting than the importer, the importer may believe it exists + * in the compiled importee when it does not, when the instantiation + * is behind a conditional debug declaration. + */ + !global.params.debuglevel && // workaround for Bugzilla 11239 ti && ti->instantiatingModule && !ti->instantiatingModule->isRoot()) { Module *mi = ti->instantiatingModule; diff --git a/test/runnable/imports/inc11239.d b/test/runnable/imports/inc11239.d new file mode 100644 index 000000000000..494f147dd2fd --- /dev/null +++ b/test/runnable/imports/inc11239.d @@ -0,0 +1,11 @@ +// REQUIRED_ARGS: + +int foo(T)(T x) +{ + return 3; +} + +debug +{ + int x = foo(2); +} diff --git a/test/runnable/test11239.d b/test/runnable/test11239.d new file mode 100644 index 000000000000..9ace1cf95ab4 --- /dev/null +++ b/test/runnable/test11239.d @@ -0,0 +1,11 @@ +// EXTRA_SOURCES: imports/inc11239.d +// REQUIRED_ARGS: -debug +// COMPILE_SEPARATELY +// PERMUTE_ARGS: + +import imports.inc11239; + +void main() +{ + foo(1); +}