[Bug c++/93585] Linker resolves variable with extern variable of same name but different type
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 5 10:26:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93585
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Norman Goldstein from comment #0)
> The type of "foo" is different in the two files:
Yes, you've violated the C++ One-Definition Rule, which means your program is
ill-formed, but the implementation is not required to diagnose it (because it's
impractical to do in some cases).
See
https://en.wikipedia.org/wiki/One_Definition_Rule
https://en.cppreference.com/w/cpp/language/definition
(and lots of other reults found by a web search)
More information about the Gcc-bugs
mailing list