The warning doesn’t state that it’s UB; it merely says that the context of use, namely sizeof
, won’t trigger the side effects (which in case of new
is allocating memory).
[expr.sizeof]
The sizeof operator yields the number of bytes occupied by a non-potentially-overlapping object of the type of its operand. The operand is either an expression, which is an unevaluated operand ([expr.prop]), or a parenthesized type-id.
The standard also helpfully explains what that means:
[expr.context] (…) An unevaluated operand is not evaluated.
It’s a fine, although a weird way to write sizeof(int*)
.