reinterpret_cast failed to cast between const and non-const member function
The following code passes g++, but fails on Sun CC 5.8
class C {
public:
void fv();
void fc() const;
};
typedef void (C::*C_FUNC)();
typedef void (C::*C_CONST_FUNC)() const;
int main()
{
C_FUNC f1 = &C::fv;
C_CONST_FUNC f2 = &C::fc;
C_CONST_FUNC f3 = reinterpret_cast<C_CONST_FUNC>(&C::fv);
C_FUNC f4 = reinterpret_cast<C_FUNC>(&C::fc);
}
"recast.cc", line 15: Error: Cannot cast away const or volatile.
"recast.cc", line 16: Error: Cannot cast away const or volatile.
2 Error(s) detected.
Is this a bug of Sun CC?
Thanks.
huoq.

