| 1 |
// { dg-do assemble } |
| 2 |
// Origin: Mark Mitchell <[email protected]> |
| 3 |
|
| 4 |
struct A { |
| 5 |
}; |
| 6 |
|
| 7 |
int main() |
| 8 |
{ |
| 9 |
A a; |
| 10 |
typedef void (A::*F)(); |
| 11 |
F p; |
| 12 |
|
| 13 |
const_cast<const A>(a); // { dg-error "3:invalid use of .const_cast." } const_cast requires pointer/ref types |
| 14 |
const_cast<F>(p); // { dg-error "3:invalid use of .const_cast." } const_cast requires pointer/ref types |
| 15 |
const_cast<int (*)()>(&main); // { dg-error "3:invalid use of .const_cast." } function type in const_cast |
| 16 |
// { dg-error "26:ISO C\\+\\+ forbids taking address" "" { target *-*-* } .-1 } |
| 17 |
const_cast<int (&)()>(main); // { dg-error "3:invalid use of .const_cast." } function type in const_cast |
| 18 |
} |