From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 76AF43870848; Mon, 18 May 2020 20:27:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76AF43870848 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589833621; bh=C2poRv0s0anQ6gANWvf1njPLe1ArFil4ykN8fS48OVg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qBp9zlQG/LoFRts3kDVfG0d//Ie3w2IMqeE0uqkFhwkiJiPTkHzMSK3F6MJuVCTPj eZ2TiQdU/S4vASetlGUZI9E+PYJJ3cIUWiGUsGx5hS0jITlNpqECT4BglDKffqJ83E Zj9QrgXyr4DfvkDG4JPKlZHO2/LwXcWt6qHPmUlw= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/87699] Implement CWG 1512 Date: Mon, 18 May 2020 20:27:01 +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: 9.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek 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: Mon, 18 May 2020 20:27:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D87699 --- Comment #7 from CVS Commits --- The master branch has been updated by Marek Polacek : https://gcc.gnu.org/g:ae8ed736addb2b005d54c0b3191ac599a04ec170 commit r11-467-gae8ed736addb2b005d54c0b3191ac599a04ec170 Author: Marek Polacek Date: Wed May 13 15:52:42 2020 -0400 c++: Implement DR 1512, Pointer comparison vs qual convs [PR87699] This patch resolves DR 1512 (and, by turn, DR 583). This entails: 1) Relational pointer comparisons against null pointer constants have been made ill-formed: void f(char *p) { if (p > 0) // ... } was always invalid in C but was -- accidentally -- allowed in C++. 2) This was ill-formed: bool foo(int** x, const int** y) { return x < y; } because 'int**' couldn't be converted to 'const int**'. This was fixed by re-defining a generic composite pointer type. The composite type of these two pointers will be 'const int *const *', to which both pointers can be converted. 3) The overload descriptions for built-in operators were adjusted, because objects of type std::nullptr_t cannot be used with relational operators any more. I fixed 1) by adjusting cp_build_binary_op; we already had a warning for it so made it a hard error now. Then 2) required tweaking composite_pointer_type_r. [expr.type] defines the composite pointer type by using the "cv-combined type." We didn't implement the [conv.qual]/3.3 part; previously the composite type of 'int**' and 'const int**' was 'const int**', so this didn't compile: void f(const int **p, int **q) { true ? p : q; } I wrote a more extensive test for this which uses decltype and some template magic to check the composite type, see composite-ptr-type.C. We still don't handle everything that [expr.type] requires us to, but it's pretty close. And finally 3) was handled in add_builtin_candidate. Turned out we weren't creating built-in operator candidates when the type was std::nullptr_t at all. We should, for =3D=3D and !=3D. Tested in buil= tin4.C. In passing, I'm fixing some of the comments too. DR 1512 PR c++/87699 * call.c (add_builtin_candidate) : Create candida= te operator functions when type is std::nullptr_t for =3D=3D/!=3D. * typeck.c (composite_pointer_type_r): Add bool a * parameter. = Use it to maybe add "const" to the pointer type. (composite_pointer_type): Update the call to composite_pointer_type_r. (cp_build_binary_op): Turn two warning_at into error_at. Print= the types. * g++.dg/cpp0x/constexpr-array-ptr10.C: Change dg-warning to dg-error and adjust the expected messages in dg-error. * g++.dg/expr/composite-ptr-type.C: New test. * g++.dg/expr/ptr-comp1.C: New test. * g++.dg/expr/ptr-comp2.C: New test. * g++.dg/expr/ptr-comp3.C: New test. * g++.dg/overload/builtin4.C: New test. * g++.dg/warn/Wextra-3.C: Change dg-warning to dg-error.=