Shafik Yaghmour

Compiler Engineer at Intel. This is a personal blog. The opinions stated here are my own, not those of my company.

Only A is well formed, the grammar:

noptr-new-declarator:
  [ expression ] attribute-specifier-seq<sub>opt</sub>
  noptr-new-declarator [ constant-expression ] attribute-specifier-seq<sub>opt</sub>

tells us the first size is an expression while subsequent sizes are constant expression.

From [expr.new]p7 we see the expression has to be implicitly convertible to size_t While the constant expression shall be a converted constant expression of type std::size_t

Every constant-expression in a noptr-new-declarator shall be a converted constant expression of type std::size_t and shall evaluate to a strictly positive value. The expression in a noptr-new-declarator is implicitly converted to std::size_t. [Example: Given the definition int n = 42, new float[n][5] is well-formed (because n is the expression of a noptr-new-declarator), but new float[5][n] is ill-formed (because n is not a constant expression). — end example]

which does not allow floating point to floating point to integral conversions:

godbolt Case A and Case B