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

clang should throw std::bad_array_new_length when the allocation size for new overflows #12016

Open
efriedma-quic opened this issue Dec 23, 2011 · 5 comments
Labels
bugzilla Issues migrated from bugzilla c++11

Comments

@efriedma-quic
Copy link
Collaborator

Bugzilla Link 11644
Version unspecified
OS All
CC @AaronBallman,@DougGregor,@emaste,@miyuki

Extended Description

C++11 has a new exception type: std::bad_array_new_length. And per the standard, "If the value of that expression is less than zero or such that the size of the allocated object would exceed the implementation-defined limit, no storage is obtained and the new-expression terminates by throwing an exception of a type that would match a handler (15.3) of type std::bad_array_new_length". Our current behavior is likely good enough in most cases, but it isn't strictly compliant.

@llvmbot
Copy link
Collaborator

llvmbot commented May 12, 2014

r208386 gives:

test.cpp:2:13: warning: expression result unused [-Wunused-value]
return (0 && ({lbl1:lbl2: 0;})), (long)&&lbl1 - (long)&&lbl2;
~ ^ ~~~~~~~~~~~~~~~~~
test.cpp:1:16: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
constexpr long a() {
^
test.cpp:2:36: note: cast that performs the conversions of a reinterpret_cast is not allowed in a
constant expression
return (0 && ({lbl1:lbl2: 0;})), (long)&&lbl1 - (long)&&lbl2;
^

Is this bug report still valid?

@llvmbot
Copy link
Collaborator

llvmbot commented May 12, 2014

Ignore the last comment please, pasted into wrong tab :(

@AaronBallman
Copy link
Collaborator

Fixed in r216675

@AaronBallman
Copy link
Collaborator

Reopening as this commit was reverted due to runtime support issues.

@TNorthover
Copy link
Contributor

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

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
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++11
Projects
None yet
Development

No branches or pull requests

4 participants