From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AC22A385BF83; Tue, 14 Apr 2020 21:56:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC22A385BF83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586901387; bh=JHkJ6YkpXhcwkmYc0xv0wvBJqxfcS9hVI6TIOLJKHiw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GYFdQE1J5pRTe+f0EK/DhVxNKftvxYaCDgEb/p47S0C/8sKaOouNCpYQ4NZdT6KnF zYnM/SrGqbCkVfJ4xGpdBcXTn0DlznpLj2L2rlklOYnxg/hihGmwTb5cQNiKMIIqUk lyEgeyx+Li6hZJsYndrGgZSKV0VN73i2t7WWeZYE= From: "daniel.kruegler at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94554] spurious -Waddress warning within "if constexpr" function-null compares Date: Tue, 14 Apr 2020 21:56:27 +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: 10.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: daniel.kruegler at googlemail 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 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, 14 Apr 2020 21:56:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94554 --- Comment #3 from Daniel Kr=C3=BCgler --- (In reply to Melissa from comment #0) > 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? The example is ill-formed because the condition of 'if constexpr' is more restricted than that of normal 'if': It expects "a contextually converted constant expression of type bool" and [expr.const] p10 lists the allowed conversions in this case. This list omits the boolean conversions ([conv.bool]). But the example would become valid when rewritten as follows: int meow() { return 1; } void kitty(int); template void test() { if constexpr (bool(F)) { kitty(F()); } else { kitty(2); } } template void test(); template void test();=