This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-05


313. Class with single conversion function to integral as array size in new

Section: 7.6.2.8  [expr.new]     Status: dup     Submitter: Bill Gibbons     Date: 22 Oct 2001

Should it be allowed to use an object of a class type having a single conversion function to an integral type as an array size in the first bound of the type in an array new?

  struct A {
    operator int();
  } a;
  int main () {
    new int[a];
  }

There are similar accommodations for the expression in a delete (7.6.2.9 [expr.delete] paragraph 1) and in a switch (8.5.3 [stmt.switch] paragraph 2) . There is also widespread existing practice on this (g++, EDG, MSVC++, and Sun accept it, and even cfront 3.0.2).

Rationale (October, 2004):

Duplicate of issue 299.