Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

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

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR11644
Status REOPENED
Importance P enhancement
Reported by Eli Friedman (efriedma@quicinc.com)
Reported on 2011-12-22 18:01:02 -0800
Last modified on 2021-03-08 12:35:12 -0800
Version unspecified
Hardware PC All
CC aaron@aaronballman.com, andrey.vul@gmail.com, dgregor@apple.com, emaste@freebsd.org, llvm-bugs@lists.llvm.org, maltsevm@gmail.com, popizdeh@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

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.

Quuxplusone commented 10 years ago
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?
Quuxplusone commented 10 years ago

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

Quuxplusone commented 10 years ago

Fixed in r216675

Quuxplusone commented 10 years ago

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