1 // { dg-do assemble } 2 // g++ 1.37.1 bug 900519_03 3 4 // The C++ Reference Manual says (in section 8.4.3) "A reference to a 5 // volatile T can be initialized with a volatile T or a plain T but not a 6 // const T. A reference to a const T can be initialized with a const T or 7 // a plain T or something that can be converted into a plain T, but not a 8 // volatile T." 9 10 // g++ fails to disgnose such errors in most cases. 11 12 // keywords: references, initialization, type qualifiers 13 14 extern const int cint_obj; 15 extern volatile int vint_obj; 16 take_cint_ref(const int & arg)17void take_cint_ref (const int& arg) { } // { dg-message "" } take_vint_ref(volatile int & arg)18void take_vint_ref (volatile int& arg) { } // { dg-message "" } 19 20 const int& global_cint_ref2 = vint_obj; // { dg-error "" } 21 22 volatile int& global_vint_ref1 = cint_obj; // { dg-error "" } 23 24 extern const int& extern_cint_ref; 25 extern volatile int& extern_vint_ref; 26 test_0()27void test_0 () 28 { 29 const int& local_cint_ref2 = vint_obj; // { dg-error "" } 30 31 volatile int& local_vint_ref1 = cint_obj; // { dg-error "" } 32 } 33 test_1()34void test_1 () 35 { 36 take_cint_ref (vint_obj); // { dg-error "" } 37 38 take_vint_ref (cint_obj); // { dg-error "" } caught 39 } 40 test_2()41void test_2 () 42 { 43 take_cint_ref (extern_vint_ref); // { dg-error "" } 44 45 take_vint_ref (extern_cint_ref); // { dg-error "" } 46 } 47 main()48int main () { return 0; } 49