[Bug c++/106269] the "operator delete" selection does not follow c++ spec

2022-09-04 Thread chumarshal at foxmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106269

--- Comment #2 from marshal  ---
(In reply to marshal from comment #0)
> #include  
> #include 
> 
> void operator delete[]( void* ptr   ) noexcept {
>  std::cout << "delete with 1 parameters==" << std::endl;
> ::operator delete(ptr);
> }
> 
> void operator delete[]( void* ptr, std::size_t size ) noexcept {
> 
>  std::cout << "delete with 2 parameters==" << std::endl;
> ::operator delete(ptr);
> }
> 
> int main()
> {
> int* p = new int[2];
> p[0] = 1;
> p[1] = 2;
> delete[] p;
> }
> 
> 
> The result is:
> delete with 1 parameters==
> 
> 
> But it does not follow c++14 spec as follow:
> 
> C++14 Standard (ISO/IEC 14882:2014), Section 5.3.5, Paragraph 10:
> "If the type is complete and if deallocation function lookup finds both a
> usual deallocation function with only a pointer parameter and a usual
> deallocation function with both a pointer parameter and a size parameter,
> then the selected deallocation function shall be the one with two
> parameters. Otherwise, the selected deallocation function shall be the
> function with one parameter."


/*
 * (c) Copyright 2017-2021 by Solid Sands B.V.,
 * Amsterdam, the Netherlands. All rights reserved.
 * Subject to conditions in the RESTRICTIONS file.
 */

[Bug c++/106269] the "operator delete" selection does not follow c++ spec

2022-07-12 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106269

Jonathan Wakely  changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from Jonathan Wakely  ---
This is the correct behaviour, see https://wg21.link/cwg1788 which changed the
standard.