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.

Reply via email to