This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/37144] A bug in include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp
- From: "hjl dot tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Dec 2008 01:17:09 -0000
- Subject: [Bug libstdc++/37144] A bug in include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp
- References: <bug-37144-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from hjl dot tools at gmail dot com 2008-12-11 01:17 -------
This program shows the problem:
[hjl@gnu-6 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;
}
[hjl@gnu-6 37144]$ g++ x.cc
[hjl@gnu-6 37144]$ ./a.out
&x.i != &t1.i
Aborted
[hjl@gnu-6 37144]$
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37144