https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106269

            Bug ID: 106269
           Summary: the "operator delete" selection does not follow c++
                    spec
           Product: gcc
           Version: rust/master
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chumarshal at foxmail dot com
  Target Milestone: ---

#include <iostream> 
#include <cstddef>

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."
  • [Bug c++/106269] New: the "... chumarshal at foxmail dot com via Gcc-bugs

Reply via email to