1// { dg-do assemble } 2// g++ 1.37.1 bug 900330_01 3// 4// As indicated by the example at the end of the section 3.5.3 of the ANSI 5// C standard, when a type qualifier (i.e. "const" or "volatile") is applied 6// to an array type, the effect should be as if the element type had been 7// qualified with the given qualifier. 8// 9// This rule applies to C++ also. 10// 11// In section 7.1.6 of the C++ Reference Manual it says "Each element of a 12// const array is const..." 13// 14// It appears however that when a name already exists for a given array type 15// (i.e. a typedef name) and when that name is qualified by a type qualifier, 16// (i.e. "const" or "volatile"), gcc & g++ may act as if the qualifier applied 17// to the named (array) type rather that to the elements of that type. 18// 19// The result is that (even with the -ansi and -pedantic options) g++ 20// generates no errors or warnings for the lines indicated (even though it 21// should). 22// 23// Due to the incorrect associations, gcc & g++ will also issue inappropriate 24// warnings in some cases (as illustrated below). 25 26// keywords: type qualifiers, arrays 27 28typedef const int const_int; 29typedef const_int array_of_const_int[3]; 30array_of_const_int *ptr_to_array_of_consts; 31 32typedef int array_of_int[3]; 33typedef const array_of_int const_array_of_int; 34const_array_of_int *ptr_to_const_array; 35 36void function_0 () 37{ 38 ptr_to_array_of_consts = ptr_to_const_array; /* gets bogus warning */ 39 ptr_to_const_array = ptr_to_array_of_consts; /* gets bogus warning */ 40} 41 42/* The following example is taken from ANSI 3.5.3 */ 43 44typedef int A[2][3]; 45const A a = {{4, 5, 6}, {7, 8, 9}}; 46int *pi; 47 48void function_1 () 49{ 50 pi = a[0]; // { dg-error "" } a[0] has type "const int *" 51} 52 53int main () { return 0; } 54