From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121757 invoked by alias); 31 Aug 2015 10:59:07 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 121693 invoked by uid 55); 31 Aug 2015 10:59:03 -0000 From: "joseph at codesourcery dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/67386] missing diagnostic on a use of an undeclared function Date: Mon, 31 Aug 2015 10:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 5.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joseph at codesourcery dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg02109.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67386 --- Comment #4 from joseph at codesourcery dot com --- On Fri, 28 Aug 2015, msebor at gcc dot gnu.org wrote: > My reading was that the implicit declaration is intended to be in effect only > for the call to the otherwise undeclared function, but GCC and the other > compilers I've tried let it persist (at least) until the end of the scope and Yes (remember, two scopes are the same if they end at the same point; saying what block the declaration appears in is the same as saying where it ends). > I think Clang and IBM xlc are both wrong since the reference to abs on line 8 > should clearly be diagnosed. The C90 words aren't completely clear about where > in the innermost block the extern int identifier(); declaration is supposed to > appear but it stands to reason that it should appear where all other > declarations must appear in C90: before any executable code. So diagnosing the In general, it's a mistake to interpret "X is equivalent to Y" statements in the C standard as referring to a textual substitution; there are plenty of other places where applying such a substitution goes wrong. Cf. cases where something is said to be equivalent to a particular sequence of declarations and statements and it must be implicitly understood that the variable names in those declarations and statements are not special in any way.