From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 99DAE395ACCC; Wed, 27 May 2020 11:43:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99DAE395ACCC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590579792; bh=xYzetZ3n0xut3wq6HdPeNmDamQ3TKv8AeGH4ZVnAKyQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yTV0POd2zw9RvNFYA/rW4t04rE0I23TlSKKZqvo9UJ/r7v04+Yn57JMizl14ZdisG AqTwWnjMqQ5gOJDC49EuCHL5FklZNJe6uSG2rQhqDDiEU9f/Q5tkS6crTS5ZWvztgN xnt7ZvHHgX7KmmRsUfUP5245MEmoy3/3ZuUiquW8= From: "haoxintu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95354] GCC misuse "nonnull-attribute" option and can not detect it as UB as well Date: Wed, 27 May 2020 11:43:12 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: haoxintu at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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 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: Wed, 27 May 2020 11:43:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95354 --- Comment #5 from Haoxin Tu --- (In reply to Jonathan Wakely from comment #4) > (In reply to Haoxin Tu from comment #3) > > I see. Are there any cases that can trigger the UB of nonnull-attribute= ? I > > doubt the usage of =E2=80=9C-fsanitize=3Dnonnull-attribute=E2=80=9D in = GCC... >=20 > Yes, just use the attribute correctly. >=20 > Using: >=20 > __attribute__((nonnull)) void has_nonnull_argument(int *p) {=20 > ;=20 > } >=20 > will cause UBsan to diagnose it: >=20 > nn.cc:7:25: runtime error: null pointer passed as argument 1, which is > declared to never be null Thanks, Jonathan, Got it ~=