public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106269] New: the "operator delete" selection does not follow c++ spec
@ 2022-07-12 12:06 chumarshal at foxmail dot com
  2022-07-12 12:26 ` [Bug c++/106269] " redi at gcc dot gnu.org
  2022-09-05  3:30 ` chumarshal at foxmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: chumarshal at foxmail dot com @ 2022-07-12 12:06 UTC (permalink / raw)
  To: gcc-bugs

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."

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-05  3:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 12:06 [Bug c++/106269] New: the "operator delete" selection does not follow c++ spec chumarshal at foxmail dot com
2022-07-12 12:26 ` [Bug c++/106269] " redi at gcc dot gnu.org
2022-09-05  3:30 ` chumarshal at foxmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).