This is the mail archive of the gcc-prs@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]

middle-end/10875: There is no multiple symbol definition error or warning for global symbols


>Number:         10875
>Category:       middle-end
>Synopsis:       There is no multiple symbol definition error or warning for global symbols
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon May 19 22:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jose Mortensen
>Release:        gcc 3.2.1
>Organization:
>Environment:
debian linux 2.4.19, HPUX B.10.20 (gcc 2.95.2)
>Description:
Two globals with the same name but different types declared in different files are resolved by the linker as one variable without an error or warning message. 

1.	Conflicting types should give an error. I don?t know if this is actually allowed  in ansi-C 
2.	Looks like Ansi-C takes this kind of code as declaration if it has already been defined, but would be handy if it could at least give a warning.

A simplified example is given below:

// file1.c
 
#include <stdio.h>

int* var;

void other_function(){
   var = NULL;
}


// file2.c

#include <stdio.h>
void other_function();

int var;

int main(int argc, char** argv)
{
   var = 1;
   other_function();
   printf("%d\n", var);
}

>How-To-Repeat:
just cut and paste the code given above and run gcc

> gcc file1.c file2.c
>Fix:
coding carefully
>Release-Note:
>Audit-Trail:
>Unformatted:


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