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