From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 32CC1384AB62; Wed, 24 Apr 2024 05:36:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32CC1384AB62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713937001; bh=6scWtOm6Zj3JyH4fvq6VjDzvaQ+Mv0gtYQGz8UwrkY8=; h=From:To:Subject:Date:From; b=CszH7ltNBgvRCyszHvrcthrJRulu0ICMWTEniKjizFInW2Y27/9L8R9wz+an0nW3p AOfpOSlxZY2zzRemAXZ+U50L9RpWRdAHd3/ACk1Hkxo4oS3S4hyT7E4XPDuc5d5kyV r5m0+JSSXiErdOnosxoFgmuwIuw0pYmyLWJYRuRs= From: "eggert at cs dot ucla.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114833] New: --suggest-attribute=returns_nonnull misdiagnoses functions with __attribute__((nonnull)) Date: Wed, 24 Apr 2024 05:36:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at cs dot ucla.edu 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D114833 Bug ID: 114833 Summary: --suggest-attribute=3Dreturns_nonnull misdiagnoses functions with __attribute__((nonnull)) Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: eggert at cs dot ucla.edu Target Milestone: --- This is gcc (GCC) 14.0.1 20240411 (Red Hat 14.0.1-0) on Fedora 40 x86-64. P= ut this code into the file t.i: extern char const *foo () __attribute__ ((returns_nonnull)); char const * foo () { return "abc"; } and compile it with: gcc -S -O2 -Wsuggest-attribute=3Dreturns_nonnull t.i The output is: t.i: In function =E2=80=98foo=E2=80=99: t.i:3:3: warning: function might be candidate for attribute =E2=80=98retu= rns_nonnull=E2=80=99 [-Wsuggest-attribute=3Dreturns_nonnull] 3 | foo () | ^~~ This diagnostic is obviously wrong, as foo is already declared with the suggested attribute.=