From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3890D386546F; Fri, 6 Oct 2023 11:56:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3890D386546F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696593411; bh=juRjld81IHea80d7S1cxm+4Q4EGbMkt9XC2DKomi4EE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OxqXkLLIYsi/C1EWbxILLSJp3rZq4zJYn5Ra8tdKUp3NDcHHP8Y4naXAVKGV2wD/+ BFcKeaAWzCmSUrdQ3YoJdQMBeXybwmAA7XNk5RmiplrQbnNhuCfzuEzrw5aAf51rfE s6EPMwrTcS28ILxDRGASz4tPbM2R88EIQqqTAp/8= From: "k.frolov at samsung dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/111708] Calling external global function instead of local static function. Date: Fri, 06 Oct 2023 11:56:49 +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: 14.0 X-Bugzilla-Keywords: accepts-invalid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: k.frolov at samsung 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: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111708 --- Comment #3 from Kirill Frolov --- Looks like example demonstrates undefined behaviour. This article=20 (https://wiki.sei.cmu.edu/confluence/display/c/DCL36-C.+Do+not+declare+an+i= dentifier+with+conflicting+linkage+classifications) contains table, which shows that I can use "extern" keyword in second declaration to refer symbol with internal linkage. So I fixed the source: static int f(int); int main(int argc, const char *argv[]) { (void)argv; return f(argc); } static int f(int f) { int x =3D f; { extern int f(int); if (x < 1) return 0; else return f(x - 1); } } The problem still persist. See an example: https://godbolt.org/z/reGbM67Kj GCC still references external function "f", but I expect that internal func= tion must be referenced instead.=