[Issue 902] Duplicate zero-initialized template member variables
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 6 05:12:19 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=902
------- Comment #2 from fvbommel at wxs.nl 2007-04-06 07:12 -------
I can't reproduce the exact original problem on DMD v1.010 but it looks like
that's because it constant-propagates Foo!(void).Foo if it's a bool (and if
it's an uint, I didn't try any other primitive types).
However, changing the type to uint[1] breaks it again:
=====
$ cat util.d
template Foo(T) {
const uint[1] Foo = 0;
}
uint[] foo() {
return Foo!(void);
}
$ cat main.d
import util;
void main() {
auto b = Foo!(void);
}
$ dmd -c main.d && dmd -c util.d && dmd main.o util.o
gcc main.o util.o -o main -m32 -lphobos -lpthread -lm -Xlinker
-L/home/urxae/opt/dmd/lib
util.o:(.bss+0x0): multiple definition of `_D4util10__T3FooTvZ3FooG1k'
main.o:(.bss+0x0): first defined here
collect2: ld returned 1 exit status
--- errorlevel 1
$ dmd -c main.d util.d && dmd main.o util.o
gcc main.o util.o -o main -m32 -lphobos -lpthread -lm -Xlinker
-L/home/urxae/opt/dmd/lib
$ dmd main.d util.d
gcc main.o util.o -o main -m32 -lphobos -lpthread -lm -Xlinker
-L/home/urxae/opt/dmd/lib
=====
So the problem remains, it's just disguised by apparently better
constant-propagation.
This stuff simply shouldn't be in .bss if it can be emitted from multiple
modules.
--
More information about the Digitalmars-d-bugs
mailing list