This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/50455] duplicate class/constructor silently accepted, wrong constructor linked


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]