[Bug c++/87699] Implement CWG 1512

2024-01-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |11.0

[Bug c++/87699] Implement CWG 1512

2021-07-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

--- Comment #11 from Andrew Pinski  ---
*** Bug 86228 has been marked as a duplicate of this bug. ***

[Bug c++/87699] Implement CWG 1512

2021-07-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Andrew Pinski  changed:

   What|Removed |Added

 CC||zhonghao at pku dot org.cn

--- Comment #10 from Andrew Pinski  ---
*** Bug 86579 has been marked as a duplicate of this bug. ***

[Bug c++/87699] Implement CWG 1512

2021-03-21 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Jonathan Wakely  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=99701

--- Comment #9 from Jonathan Wakely  ---
(In reply to CVS Commits from comment #7)
> 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.

This apparently wasn't completely done, see PR 99701.

[Bug c++/87699] Implement CWG 1512

2020-05-18 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Marek Polacek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #8 from Marek Polacek  ---
Implemented in GCC 11.

[Bug c++/87699] Implement CWG 1512

2020-05-18 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

--- 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 == and !=.  Tested in builtin4.C.
In passing, I'm fixing some of the comments too.

DR 1512
PR c++/87699
* call.c (add_builtin_candidate) : Create candidate
operator functions when type is std::nullptr_t for ==/!=.
* 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.

[Bug c++/87699] Implement CWG 1512

2020-04-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

--- Comment #6 from Marek Polacek  ---
See Daniel's testcase for why this is more important than it might seem:

template
bool test(T*)
{
  return true;
}

int main()
{
  test((int*)(nullptr));
}

[Bug c++/87699] Implement CWG 1512

2020-04-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Marek Polacek  changed:

   What|Removed |Added

 CC||daniel.kruegler@googlemail.
   ||com

--- Comment #5 from Marek Polacek  ---
*** Bug 94563 has been marked as a duplicate of this bug. ***

[Bug c++/87699] Implement CWG 1512

2020-04-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Marek Polacek  changed:

   What|Removed |Added

   Assignee|beliveau0213 at gmail dot com  |mpolacek at gcc dot 
gnu.org
 CC||mpolacek at gcc dot gnu.org

--- Comment #4 from Marek Polacek  ---
Mine, for GCC 11.

[Bug c++/87699] Implement CWG 1512

2019-05-28 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

[Bug c++/87699] Implement CWG 1512

2019-05-25 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek  ---
The warning is in place and triggers with -Wextra:

warning (OPT_Wextra,
 "ordered comparison of pointer with integer zero");

I guess we should make it a permerror.

[Bug c++/87699] Implement CWG 1512

2018-10-23 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Martin Sebor  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=81453

--- Comment #2 from Martin Sebor  ---
I raised bug 81453 for this against the C front end, but only to move the
warning GCC issues with -Wextra to -Wall.

[Bug c++/87699] Implement CWG 1512

2018-10-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-10-23
 CC||msebor at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
Confirmed.

Martin, I thought this was a dup of an existing bug that you'd filed or
commented on, but can't find anything. Am I imagining it?