LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 11644 - clang should throw std::bad_array_new_length when the allocation size for new overflows
Summary: clang should throw std::bad_array_new_length when the allocation size for new...
Status: REOPENED
Alias: None
Product: clang
Classification: Unclassified
Component: C++11 (show other bugs)
Version: unspecified
Hardware: PC All
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-22 18:01 PST by Eli Friedman
Modified: 2021-03-08 12:35 PST (History)
7 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eli Friedman 2011-12-22 18:01:02 PST
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.
Comment 1 Nikola Smiljanić 2014-05-11 20:29:42 PDT
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?
Comment 2 Nikola Smiljanić 2014-05-12 00:34:55 PDT
Ignore the last comment please, pasted into wrong tab :(
Comment 3 Aaron Ballman 2014-08-28 11:51:00 PDT
Fixed in r216675
Comment 4 Aaron Ballman 2014-08-28 16:52:39 PDT
Reopening as this commit was reverted due to runtime support issues.