Shafik Yaghmour

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

It is ill-formed, reinterpret_cast is not allowed to cast away constness [expr.reinterpret.cast]p2

The reinterpret_­cast operator shall not cast away constness. An expression of integral, enumeration, pointer, or pointer-to-member type can be explicitly converted to its own type; such a cast yields the value of its operand.

Using it over C-style cast catches errors and clarifies intent -Wold-style-cast FTW!

Obligatory godbolt