http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52216

             Bug #: 52216
           Summary: [C++11][noexcept] Wrong exception deduction for some
                    forms of placement new
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: daniel.krueg...@googlemail.com


gcc 4.7.0 20111210 (experimental) rejects the following program:

//--
#include <new>

int n;

static_assert(!noexcept(::new (std::nothrow) int[n]), "");
//--

Further the following program aborts even though it shouldn't:

//---
#include <new>

extern "C" void abort();

void test_too_small(int n) {
 new (std::nothrow) int[n]{1,2,3,4};
}

int main()
{
  bool f = false;
  try {
    test_too_small(3);
  } catch (...) {
    f = true;
  }
  if (!f)
    abort();
}
//---

Rationale: According to [expr.new] p7:

"[..] if the new-initializer is a bracedinit-list for which the number of
initializer-clauses exceeds the number of elements to initialize, 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
(18.6.2.2)."

I guess that part of the problem is due to the currently missing support of
type std::bad_array_new_length.

Reply via email to