[Bug c++/93585] New: Linker resolves variable with extern variable of same name but different type
normvcr at telus dot net
gcc-bugzilla@gcc.gnu.org
Wed Feb 5 03:54:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93585
Bug ID: 93585
Summary: Linker resolves variable with extern variable of same
name but different type
Product: gcc
Version: 9.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: normvcr at telus dot net
Target Milestone: ---
Here are two source files which compile and link without error, but which break
type expectations and not what the programmer would want. The type of "foo" is
different in the two files:
a.cpp:
//////
double foo = 2.1;
b.cpp
//////
#include <iostream>
using namespace std;
extern int foo;
int main( int argc, char* argv[] )
{
cout << "foo= " << foo << endl;
return 0;
}
////////////
On Windows 10, the visual studio cl.exe complains at link time.
More information about the Gcc-bugs
mailing list