From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 547E0385841B; Tue, 22 Feb 2022 11:16:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 547E0385841B From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/104633] [12 Regression] -Winfinite-recursion diagnoses fortify wrappers Date: Tue, 22 Feb 2022 11:16:45 +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: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org 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: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2022 11:16:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104633 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- (In reply to Richard Biener from comment #2) > The following is a valid use of extern inline I think >=20 > extern int memcmp (const void * p, const void *q, unsigned long size); >=20 > extern inline __attribute__((always_inline,gnu_inline)) > int memcmp (const void * p, const void *q, unsigned long size) > { > return memcmp (p, q, size); > } I think the above isn't actually valid, the compiler should still inline it infinitely. This is an infinite recursion. extern inline __attribute__((always_inline,gnu_inline)) int memcmp (const void * p, const void *q, unsigned long size) { return __builtin_memcmp (p, q, size); } is ok, __builtin_memcmp there doesn't mean it should use the user memcmp inline, it should handle it as the builtin and if it decides it wants to ca= ll, will call memcmp (but the out of line one). What glibc uses are either the call __builtin_whatever forms, or call an al= ias, say: extern int __memcmp_alias (const void *, const void *, unsigned long) __asm ("memcmp"); extern inline __attribute__((always_inline,gnu_inline)) int memcmp (const void * p, const void *q, unsigned long size) { return __memcmp_alias (p, q, size); } This one is also fine, it should call the external function, not the inline recursively. So, -Winfinite-recursion shouldn't warn about these 2 forms and should warn about the #c2 case.=