From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10421 invoked by alias); 12 Dec 2002 17:16:07 -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 10407 invoked by uid 71); 12 Dec 2002 17:16:06 -0000 Date: Thu, 12 Dec 2002 09:16:00 -0000 Message-ID: <20021212171606.10406.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Christian Ehrhardt" Subject: Re: c/7741: [<3.2,3.3> regression] ICE on conflicting types (make_decl_rtl at varasm.c:834) Reply-To: "Christian Ehrhardt" X-SW-Source: 2002-12/txt/msg00718.txt.bz2 List-Id: The following reply was made to PR c/7741; it has been noted by GNATS. From: "Christian Ehrhardt" To: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org, gnats@kayari.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c/7741: [<3.2,3.3> regression] ICE on conflicting types (make_decl_rtl at varasm.c:834) Date: Thu, 12 Dec 2002 18:06:22 +0100 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7741 Hi, this PR is about the following illegal code triggering an ICE, I analyzed why: int main() { char c; int i; int c = i; } The problem is in duplicate_decls. When duplicate_decl sees the second declaration for c with the initializer it effectivly replaces the first declaration with the second leading to the equivilent of this code: int main () { int c = i; int i; } with the exception that the now undeclared identifier i in the initialization auf c is not detected. This will cause the ICE later on. I suggest that we replace unconditionally set DECL_INITIAL to NULL in duplicate_decls and possibly print an additional warning if the initializer like this: --- gcc-cvs/gcc/gcc/c-decl.c.orig Thu Dec 12 17:59:13 2002 +++ gcc-cvs/gcc/gcc/c-decl.c Thu Dec 12 18:03:34 2002 @@ -1554,7 +1554,7 @@ return 0; /* Copy most of the decl-specific fields of NEWDECL into OLDDECL. - But preserve OLDDECL's DECL_UID. */ + But preserve OLDDECL's DECL_UID and drop the initializer. */ { unsigned olddecl_uid = DECL_UID (olddecl); @@ -1562,6 +1562,10 @@ (char *) newdecl + sizeof (struct tree_common), sizeof (struct tree_decl) - sizeof (struct tree_common)); DECL_UID (olddecl) = olddecl_uid; + /* This is necessary because the initializer might contain references + to varialbes that were declared between olddecl and newdecl. This + will make the initializer invalid for olddecl. */ + DECL_INITIAL (olddecl) = NULL; } /* NEWDECL contains the merged attribute lists. regards Christian -- THAT'S ALL FOLKS!