According to [expr.cast]/4, a C-style cast tries the following casts in order:
const_cast
static_cast
static_cast
followed byconst_cast
reinterpret_cast
reinterpret_cast
followed byconst_cast
The following cast is well-formed:
const_cast<int&>(static_cast<const int&>(0))
Yet both GCC and Clang reject the cast (int&)0
. Why?