1 |
305 |
jeremybenn |
// { dg-do assemble }
|
2 |
|
|
// g++ 1.37.1 bug 900520_03
|
3 |
|
|
|
4 |
|
|
// The C++ Reference Manual says (in section 8.2.4):
|
5 |
|
|
|
6 |
|
|
// When an identifier of array type appears in an expression, except
|
7 |
|
|
// as the operand of sizeof or & or used to initialize a reference,
|
8 |
|
|
// it is converted into a pointer to the first member of the array.
|
9 |
|
|
|
10 |
|
|
// One must assume from the verbage, that when the name of a non-const array
|
11 |
|
|
// object appears in one of the exempted contexts mentioned in this passage,
|
12 |
|
|
// that it is *not* automatically converted into a pointer value, but rather
|
13 |
|
|
// that it remains as an array type value, and that it may therefore also
|
14 |
|
|
// still be an lvalue, and may be used to initialize references.
|
15 |
|
|
|
16 |
|
|
// As the following code demonstrates, g++ does in fact treat the names
|
17 |
|
|
// of non-const array objects as valid initializers for reference-to-array
|
18 |
|
|
// type object in some (but not all) contexts.
|
19 |
|
|
|
20 |
|
|
// The exception is that g++ does not allow names which designate objects
|
21 |
|
|
// on incomplete array types to be used as actual parameters in function
|
22 |
|
|
// calls where the corresponding formal parameter is of a reference-to-array
|
23 |
|
|
// type.
|
24 |
|
|
|
25 |
|
|
// g++ does however allow other similar sorts of initializations of non-formal
|
26 |
|
|
// reference objects.
|
27 |
|
|
|
28 |
|
|
// 5/16/94 (jason): The 1/25/94 WP explicitly states in section 8.3.5 that
|
29 |
|
|
// parameter types may not contain pointers or references to arrays of unknown
|
30 |
|
|
// bound. g++ is correct.
|
31 |
|
|
|
32 |
|
|
// keywords: reference types, array types, initialization, parameter passing
|
33 |
|
|
|
34 |
|
|
typedef int u_array[];
|
35 |
|
|
typedef u_array &u_array_ref;
|
36 |
|
|
|
37 |
|
|
void take_u_array_ref (u_array_ref arg) { } // { dg-error "" } reference to array of unknown bound in parmtype
|
38 |
|
|
|
39 |
|
|
extern u_array u_array_gbl_obj;
|
40 |
|
|
u_array_ref u_array_ref_gbl_obj0 = u_array_gbl_obj; // OK
|
41 |
|
|
|
42 |
|
|
void test_local_initialization ()
|
43 |
|
|
{
|
44 |
|
|
u_array_ref u_array_ref_lcl_obj0 = u_array_gbl_obj; // OK
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
void test_passing ()
|
48 |
|
|
{
|
49 |
|
|
take_u_array_ref (u_array_gbl_obj);
|
50 |
|
|
}
|