1// { dg-do run } 2// { dg-options "-O2" } 3// Origin: suckfish@ihug.co.nz 4 5// DECLARATIONS 6 7struct Record { 8 Record (int bb) : 9 b (bb) 10 { } 11 int extra; // Having an extra member in record is crucial. 12 int b; 13}; 14 15struct Container { 16 Record record; 17 // The const on the next line is crucial. 18 Container ( const Record b) : record(b) {} 19}; 20 21 22// TEST FOR CORRECT BEHAVIOR 23 24int myArray[3]; 25int * intp = myArray; 26 27void use_pair (const Container & c) 28{ 29 *intp++ = c.record.b; 30} 31 32extern "C" int printf (const char *,...); 33 34int main() 35{ 36 use_pair (Container (1234)); 37 38 if (myArray[0] != 1234) 39 return 1; 40} 41