From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4620B385841A; Sat, 4 Dec 2021 06:52:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4620B385841A From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52145] [C++11] [DR 903] zero-valued integer constant expression should prefer conversion to pointer Date: Sat, 04 Dec 2021 06:52:33 +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: 4.7.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: blocked alias 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: Sat, 04 Dec 2021 06:52:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52145 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|88655 |94404 Alias| |cwg903 --- Comment #11 from Andrew Pinski --- Here is a testcase which tests all of the null pointerness in C++11 (+): #include extern "C" int puts(const char*); typedef unsigned long uint64_t; typedef long int64_t; struct Foo { Foo(int64_t) { } }; bool t =3D true; void foo(const char*) { if (t) __builtin_abort(); puts("In foo(const char*)"); } void foo(const Foo&) { if (!t) __builtin_abort(); puts("In foo(const Foo&)"); } int main() { #if __cplusplus >=3D 201103L t=3D true; #else t=3D false; #endif foo((int)0); foo((unsigned)0); foo((short)0); foo((unsigned short)0); foo((int64_t)0); foo((uint64_t)0); foo(int()); #if __cplusplus >=3D 201103L foo(int{}); t=3D false; foo(nullptr); #endif foo(0u); foo(0ul); foo(0ull); foo(0); foo(NULL); } ---- CUT ---- We get this right for C++98 but wrong for C++11. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D88655 [Bug 88655] Different overloaded function being called depending on which compiler is used https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94404 [Bug 94404] [meta-bug] C++ core issues=