gcc/testsuite/g++.dg/opt/rtti1.C
raw| 1 | // Test that typeid sees through references even when optimizing. |
| 2 | // { dg-do run } |
| 3 | // { dg-options "-O2" } |
| 4 | |
| 5 | #include <typeinfo> |
| 6 | |
| 7 | struct A |
| 8 | { |
| 9 | virtual ~A() { } |
| 10 | }; |
| 11 | |
| 12 | class B : public A { }; |
| 13 | |
| 14 | int main () |
| 15 | { |
| 16 | B b; |
| 17 | A &aref = b; |
| 18 | |
| 19 | return typeid (aref) != typeid (b); |
| 20 | } |