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++/66316] Usage of wrong template function for classes in different modules but having the same name


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66316

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Alexander Trufanov from comment #0)
> Application has two .cpp modules. Let's say 1.cpp and 2.cpp.
> In each module there is a definition of struct N. Name N is the same for
> both. So we have two different structure declarations with the same name N.
> Compiler gives ok for such naming as they are not exposed from their modules
> and used internally in them. No namespaces are used.
> 
> And structures have different number of fields. One has 1 field and another
> is 6 fields long.

You are violating the One Definition Rule, that's a bug in your program. If you
want names to be local, you can use an anonymous namespace.

Note that the word "module" in unclear. Those are two translation units. If you
compile them into separate shared libraries (for instance), using private
visibility could also help.


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