Skip to content

MS compatibility: placement operator new[] falls back to operator new #13536

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

Closed
llvmbot opened this issue Jun 21, 2012 · 4 comments
Closed

MS compatibility: placement operator new[] falls back to operator new #13536

llvmbot opened this issue Jun 21, 2012 · 4 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@llvmbot
Copy link
Member

llvmbot commented Jun 21, 2012

Bugzilla Link 13164
Resolution FIXED
Resolved on May 29, 2013 20:57
Version trunk
OS All
Blocks llvm/llvm-bugzilla-archive#13707
Reporter LLVM Bugzilla Contributor
CC @AaronBallman,@DougGregor,@tritao

Extended Description

MSVC 10 (and presumably the previous versions as well) will compile the following without errors

#include <stddef.h>
struct arbitrary_t {} arbitrary;
void * operator new(size_t size, arbitrary_t);

int main() {
    int * p = new(arbitrary) int[4];
}

On the other hand, clang will (correctly) report

test.cpp:7:15: error: no matching function for call to 'operator new[]'
    int * p = new(arbitrary) int[4];
              ^  ~~~~~~~~~~~

Unfortunately, the header in MS's WDK only contains the non-array version of operator new(std::size_t, std::nothrow), which prevents anything that depends on WDK from being buildable with clang.

@llvmbot
Copy link
Member Author

llvmbot commented Jun 21, 2012

Note that MSVC will diagnose when the operator new function is looked up directly:

int * p = (int*)::operator new[](sizeof(int), arbitrary);

error C2039: 'new[]' : is not a member of '`global namespace''

@llvmbot
Copy link
Member Author

llvmbot commented Jun 21, 2012

Fix (no tests, -fsyntax-only): avakar/clang@9f61719

@AaronBallman
Copy link
Collaborator

Fixed in r182905

@tritao
Copy link
Mannequin

tritao mannequin commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#13707

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

2 participants