[Bug c++/50455] duplicate class/constructor silently accepted, wrong constructor linked
eda-qa at disemia dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 19 12:23:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50455
--- Comment #1 from eda-qa at disemia dot com 2011-09-19 12:20:24 UTC ---
The compiler/linker is silently ignoring that a class has been defined twice
and this results in the linker linking to the incorrect constructor at
instantiation time.
This was found in a large set of libraries, but the two attached files
reproduce the same problem.
Reproduce:
- Compile a program using the attached files and the instantiation in main()
will use the wrong constructor.
g++ -o test main.cpp duplicate.cpp
Now, with optimizations the correct constructor is used, presumably since it is
inlined and thus not subject to linking:
g++ -O3 -o test main.cpp duplicate.cpp
NOTE: The code is *invalid* but emits no diagnostic as one would expect. The
issue is thus that the linker would be expected to emit a diagnostic message,
likely an error about duplicate symbol.
More information about the Gcc-bugs
mailing list