From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7CC763857C4A; Sun, 9 Aug 2020 23:00:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CC763857C4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597014044; bh=LqmQx0PoZw9vSqlk0yFvZIeYfBl1rKXXDSWSI0kGD10=; h=From:To:Subject:Date:From; b=R+msgicVUID5NUIx7F7jmAFI+/Fzve8+pE0vy7P/Zh7WpJ+0Up7qVKXHQkPnsRq07 ab1r/QC5RGBEHKQfMXUIHEAQluTyQXWJwjOCwhO3wQcvF/mqaWTwOoyIToSMXg7eIF EmSLSk0vJ94Vw8F30l3iTWqQiBu/BH3ome4hGUM4= From: "vlad at petric dot cc" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96543] New: null check on template pointer parameter fails Date: Sun, 09 Aug 2020 23:00:44 +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.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vlad at petric dot cc 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: Sun, 09 Aug 2020 23:00:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96543 Bug ID: 96543 Summary: null check on template pointer parameter fails Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vlad at petric dot cc Target Milestone: --- static unsigned c =3D 0; template struct A { static void test() { if constexpr (c) ++ *c; } }; int main() { A<&c>::test(); A::test(); } The error is: bug.cc: In instantiation of =E2=80=98static void A::test() [with unsigne= d int* c =3D (& c)]=E2=80=99: bug.cc:11:10: required from here bug.cc:11:5: error: the address of =E2=80=98c=E2=80=99 will never be NULL [= -Werror=3Daddress] 11 | A<&c>::test(); The only fix is to remove the if constexpr (nothing else helps).=