From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 05ABC385B835; Fri, 10 Apr 2020 18:58:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05ABC385B835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586545128; bh=QZCWwLQr6Fic0GqiInT2rRaTXDMWUMfTsxhpLbBbWkY=; h=From:To:Subject:Date:From; b=qi33htvQeftpL56uwmD0W6ys1hLRanZs9zqfp+Ya5QIxvrMAUD7xFq6w22iXxxyie reLLhh/Lvz730akLCIj2wJ8bkNM9Vq8vIuML2CO16P/QtydNm3/mWZ3zeqO4VGayOt NUlhIvQfnMP+9GvInvMyceZmZ122QzpHUrJqaJYM= From: "myriachan at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94554] New: spurious -Waddress warning within "if constexpr" function-null compares Date: Fri, 10 Apr 2020 18:58:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: myriachan at gmail 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: 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 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: Fri, 10 Apr 2020 18:58:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94554 Bug ID: 94554 Summary: spurious -Waddress warning within "if constexpr" function-null compares Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: myriachan at gmail dot com Target Milestone: --- The following with -std=3Dc++17 -Waddress: int meow() { return 1; } void kitty(int); template void test() { if constexpr (F) { kitty(F()); } else { kitty(2); } } template void test(); template void test(); gives a spurious/pointless warning: : In instantiation of 'void test() [with int (* F)() =3D meow]': :12:26: required from here :5:5: warning: the address of 'int meow()' will never be NULL [-Waddress] 5 | if constexpr (F) { | ^~ The warning should be suppressed in "if constexpr" contexts, because of cou= rse it's going to be always true or always false. Clang errors on this case, so it's possible that my code is invalid: Is it legal to compare a function pointer against null in a constant-expression?=