Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chumarshal1 opened this issue Jul 13, 2022 · 4 comments
Closed

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

chumarshal1 opened this issue Jul 13, 2022 · 4 comments
Labels
c++14 clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@chumarshal1
Copy link

chumarshal1 commented Jul 13, 2022

/*
 * (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

@shafik
Copy link
Collaborator

shafik commented Jul 13, 2022

If I understand correctly clang does not support this by default but we use -fsized-deallocation to enable this. See the discussion in C++14: Disable sized deallocation by default due to ABI breakage.

Although it looks like enabling this by default is being worked on in Enable sized deallocation by default in C++14 onwards but from the last update there are some challenges.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Jul 13, 2022
@llvmbot
Copy link
Member

llvmbot commented Jul 13, 2022

@llvm/issue-subscribers-clang-frontend

@shafik shafik added the c++14 label Jul 13, 2022
@llvmbot
Copy link
Member

llvmbot commented Jul 13, 2022

@llvm/issue-subscribers-c-14

@h-vetinari
Copy link
Contributor

Now that #90373 landed, this can probably be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++14 clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

6 participants