Skip to content

the "operator delete" selection does not follow c++ spec #56505

Closed
@chumarshal1

Description

@chumarshal1
/*
 * (c) Copyright 2017-2019 by Solid Sands B.V.,
 *     Amsterdam, the Netherlands. All rights reserved.
 *     Subject to conditions in the RESTRICTIONS file.
 */
#include <cstddef>
#include <iostream> 

class My_Class 
{
public:
    int a;
    int b;
    ~My_Class(){};
};

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()
{
   My_Class* pobj = new My_Class[2];
   delete[] pobj;
}
# The clang result is:
====delete with 1 parameters======
# But gcc result is:
====delete with 2 parameters======

I think clang does not follow c++ spec as follow:
https://cplusplus.github.io/CWG/issues/1788.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++14clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions