------- Comment #12 from hjl dot tools at gmail dot com 2008-12-11 01:17 ------- This program shows the problem:
[EMAIL PROTECTED] 37144]$ cat x.cc #include <stdlib.h> #include <stdio.h> struct T1 { int i; T1 () { i = 0; } T1 (int x) { i = x; } T1 (const T1 &x) { i = x.i; } T1& operator=(T1 & __p) { i = __p.i; return *this; } }; struct pair { T1 first; T1 second; pair() : first(), second() { } pair(const T1 & __a, const T1 & __b) : first(__a), second(__b) { } pair& operator=(pair& __p) { first = __p.first; second = __p.second; return *this; } }; typedef const T1& const_T1_reference; typedef const pair & const_pair_reference; const_T1_reference extract_key_imp(const_pair_reference r_val) { return r_val.first; } const_T1_reference extract_key_imp(const_T1_reference r_val) { return r_val; } int main () { T1 t1 (21), t2 (3); pair p (t1, t2); const_T1_reference x = extract_key_imp (p); const_T1_reference y = extract_key_imp (t1); if (y.i != t1.i) abort (); if (&y.i != &t1.i) abort (); if (x.i != t1.i) abort (); if (&x.i != &t1.i) { printf ("&x.i != &t1.i\n"); abort (); } return 0; } [EMAIL PROTECTED] 37144]$ g++ x.cc [EMAIL PROTECTED] 37144]$ ./a.out &x.i != &t1.i Aborted [EMAIL PROTECTED] 37144]$ -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37144