Title
Class with single conversion function to integral as array size in new
Status
dup
Section
7.6.2.8 [expr.new]
Submitter
Bill Gibbons

Created on 2001-10-22.00:00:00 last changed 245 months ago

Messages

Date: 2004-10-15.00:00:00

Rationale (October, 2004):

Duplicate of issue 299.

Date: 2022-11-20.07:54:16

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).

History
Date User Action Args
2004-11-07 00:00:00adminsetmessages: + msg1108
2004-11-07 00:00:00adminsetstatus: open -> dup
2001-10-22 00:00:00admincreate