public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* middle-end/10875: There is no multiple symbol definition error or warning for global symbols
@ 2003-05-19 22:06 jmortensen
  0 siblings, 0 replies; only message in thread
From: jmortensen @ 2003-05-19 22:06 UTC (permalink / raw)
  To: gcc-gnats

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]


>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:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-19 22:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-19 22:06 middle-end/10875: There is no multiple symbol definition error or warning for global symbols jmortensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).