From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21633 invoked by alias); 9 May 2003 07:06:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 21400 invoked by uid 71); 9 May 2003 07:06:01 -0000 Resent-Date: 9 May 2003 07:06:01 -0000 Resent-Message-ID: <20030509070601.21398.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, bhuang@qubit-star.com Received: (qmail 18735 invoked by uid 48); 9 May 2003 07:05:13 -0000 Message-Id: <20030509070513.18734.qmail@sources.redhat.com> Date: Fri, 09 May 2003 07:06:00 -0000 From: bhuang@qubit-star.com Reply-To: bhuang@qubit-star.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/10697: linker problem with global variable X-SW-Source: 2003-05/txt/msg00697.txt.bz2 List-Id: >Number: 10697 >Category: c >Synopsis: linker problem with global variable >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: pessimizes-code >Submitter-Id: net >Arrival-Date: Fri May 09 07:06:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: falls huang >Release: gcc version 3.1 20020927 ; gcc version 3.2 >Organization: >Environment: redhat 8.0, redhat 9.0, cygwin >Description: foo.h: /*********/ int foo_global; void f(void); /*********/ a.c: /*********/ #include "foo.h" int main() { foo_global = 5; printf("foo_global=%d\n",foo_global); f(); printf("foo_global=%d\n",foo_global); return 0; } /*********/ b.c: /*********/ #include "foo.h" void f(void) { foo_global = -1; } /*********/ Makefile: all: gcc -c b.c gcc -c a.c gcc -o test a.o b.o gcc -o test1 -ansic a.c b.c clean: rm -f *.o *.exe test test1 I type "make" in console and compile the program without any warning and error. But I can't compile it successfully in TurboC3.0 and Borland C.The foo_global that defined in foo.h is included in a.c and b.c, so I think the linker should report an error when I link a.o and b.o , but gcc doesn't give any warning and error. >How-To-Repeat: Create foo.h a.c b.c makefile from my description and type "make" to compile it. >Fix: >Release-Note: >Audit-Trail: >Unformatted: