public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dfeathers at omnitrol dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/36567] New: Cannot use std::tr1::tie() with unordered_map<> of std::vector<> Date: Wed, 18 Jun 2008 19:05:00 -0000 [thread overview] Message-ID: <bug-36567-16348@http.gcc.gnu.org/bugzilla/> (raw) DESCRIPTION The following code compiles on Intel without issue with gcc-4.1.3 and gcc-4.2, but fails at LINE=29 on cross-compile with ppc_85xx-gcc-4.0: $ cat -n Foo.cc 1 2 #include <tr1/tuple> 3 #include <tr1/unordered_map> 4 #include <vector> 5 #include <string> 6 7 typedef std::vector<int> IntVector; 8 typedef std::tr1::unordered_map<std::string, IntVector, std::tr1::hash<std::string> > VectorMap; 9 10 class Foo 11 { 12 public: 13 Foo(VectorMap& map) : map_(map) {} 14 void insert(std::string s, int value); 15 16 private: 17 VectorMap& map_; 18 }; 19 20 void Foo::insert(std::string s, int value) 21 { 22 bool vector_exists = true; 23 24 VectorMap::iterator i = map_.find(s); 25 if (i == map_.end()) 26 { 27 IntVector v; 28 std::pair<std::string, IntVector> p(s, v); 29 std::tr1::tie(i, vector_exists) = map_.insert(p); 30 } 31 32 if (!vector_exists) 33 { 34 return; 35 } 36 37 (*i).second.push_back(value); 38 } 39 $ ppc_85xx-g++ -v -save-temps -c Foo.cc Using built-in specs. Target: powerpc-linux Configured with: /opt/eldk/build/ppc-2006-01-11/work/usr/src/denx/BUILD/crosstool-0.35/build/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux/gcc-4.0.0/configure --target=powerpc-linux --host=i686-host_pc-linux-gnu --prefix=/var/tmp/eldk.BjN6Wo/usr/crosstool/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux --with-headers=/var/tmp/eldk.BjN6Wo/usr/crosstool/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux/powerpc-linux/include --with-local-prefix=/var/tmp/eldk.BjN6Wo/usr/crosstool/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux/powerpc-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long Thread model: posix gcc version 4.0.0 (DENX ELDK 4.0 4.0.0) /opt/exported/ppc/eldk/toolchain/release-4.0/usr/bin/../libexec/gcc/powerpc-linux/4.0.0/cc1plus -E -quiet -v -iprefix /opt/exported/ppc/eldk/toolchain/release-4.0/usr/bin/../lib/gcc/powerpc-linux/4.0.0/ -D_GNU_SOURCE -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix Foo.cc -mcpu=8540 -mfloat-gprs=yes -mspe=yes -mabi=spe -fpch-preprocess -o Foo.ii ignoring nonexistent directory "/opt/exported/ppc/eldk/toolchain/release-4.0/usr/lib/gcc/powerpc-linux/4.0.0/../../../../include/c++/4.0.0" ignoring nonexistent directory "/opt/exported/ppc/eldk/toolchain/release-4.0/usr/lib/gcc/powerpc-linux/4.0.0/../../../../include/c++/4.0.0/backward" ignoring nonexistent directory "/opt/exported/ppc/eldk/toolchain/release-4.0/usr/lib/gcc/powerpc-linux/4.0.0/../../../../powerpc-linux/sys-include" ignoring nonexistent directory "/opt/exported/ppc/eldk/toolchain/release-4.0/usr/lib/gcc/powerpc-linux/4.0.0/../../../../powerpc-linux/include" #include "..." search starts here: #include <...> search starts here: /opt/exported/ppc/eldk/toolchain/release-4.0/usr/lib/gcc/powerpc-linux/4.0.0/include /opt/exported/ppc/eldk/toolchain/release-4.0/ppc_85xx/usr/include/c++/4.0.0 /opt/exported/ppc/eldk/toolchain/release-4.0/ppc_85xx/usr/include/c++/4.0.0/powerpc-linux /opt/exported/ppc/eldk/toolchain/release-4.0/ppc_85xx/usr/include/c++/4.0.0/backward /opt/exported/ppc/eldk/toolchain/release-4.0/usr/../ppc_85xx/usr/include End of search list. /opt/exported/ppc/eldk/toolchain/release-4.0/usr/bin/../libexec/gcc/powerpc-linux/4.0.0/cc1plus -fpreprocessed Foo.ii -quiet -dumpbase Foo.cc -mcpu=8540 -mfloat-gprs=yes -mspe=yes -mabi=spe -auxbase Foo -version -o Foo.s GNU C++ version 4.0.0 (DENX ELDK 4.0 4.0.0) (powerpc-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.3 2.96-113). GGC heuristics: --param ggc-min-expand=81 --param ggc-min-heapsize=96936 /opt/exported/ppc/eldk/toolchain/release-4.0/ppc_85xx/usr/include/c++/4.0.0/tr1/tuple_iterate.h: In constructor 'std::tr1::tuple<_T1, _T2, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass, std::tr1::_NullClass>::tuple(const std::pair<_U1, _U2>&) [with _U1 = Internal::hashtable_iterator<std::pair<const std::string, IntVector>, false, false>, _U2 = bool, _T1 = Internal::hashtable_iterator<std::pair<const std::string, IntVector>, false, false>&, _T2 = bool&]': Foo.cc:29: instantiated from here /opt/exported/ppc/eldk/toolchain/release-4.0/ppc_85xx/usr/include/c++/4.0.0/tr1/tuple_iterate.h:58: error: invalid initialization of reference of type 'Internal::hashtable_iterator<std::pair<const std::string, IntVector>, false, false>&' from expression of type 'const Internal::hashtable_iterator<std::pair<const std::string, IntVector>, false, false>' /opt/exported/ppc/eldk/toolchain/release-4.0/ppc_85xx/usr/include/c++/4.0.0/tr1/tuple_iterate.h:58: error: invalid initialization of reference of type 'bool&' from expression of type 'const bool' #------------------------------------------------------------------------------- WORKAROUND Replace LINE=29 with lines 30..33 inclusive as shown below. $ cat -n Foo2.cc 1 2 #include <tr1/tuple> 3 #include <tr1/unordered_map> 4 #include <vector> 5 #include <string> 6 7 typedef std::vector<int> IntVector; 8 typedef std::tr1::unordered_map<std::string, IntVector, std::tr1::hash<std::string> > VectorMap; 9 10 class Foo2 11 { 12 public: 13 Foo2(VectorMap& map) : map_(map) {} 14 void insert(std::string s, int value); 15 16 private: 17 VectorMap& map_; 18 }; 19 20 void Foo2::insert(std::string s, int value) 21 { 22 bool vector_exists = true; 23 24 VectorMap::iterator i = map_.find(s); 25 if (i == map_.end()) 26 { 27 IntVector v; 28 std::pair<std::string, IntVector> p(s, v); 29 // std::tr1::tie(i, vector_exists) = map_.insert(p); // broken 30 std::pair<VectorMap::iterator, bool> result(map_.end(), false); 31 result = map_.insert(p); 32 i = result.first; 33 vector_exists = result.second; 34 } 35 36 if (!vector_exists) 37 { 38 return; 39 } 40 41 (*i).second.push_back(value); 42 } 43 -- Summary: Cannot use std::tr1::tie() with unordered_map<> of std::vector<> Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dfeathers at omnitrol dot com GCC build triplet: i686-host_pc-linux-gnu GCC host triplet: i686-host_pc-linux-gnu GCC target triplet: powerpc-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36567
next reply other threads:[~2008-06-18 19:05 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-06-18 19:05 dfeathers at omnitrol dot com [this message] 2008-06-18 19:18 ` [Bug c++/36567] " dfeathers at omnitrol dot com 2008-06-18 22:14 ` paolo dot carlini at oracle dot com 2008-07-08 22:35 ` dfeathers at omnitrol dot com 2008-07-09 11:19 ` paolo dot carlini at oracle dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-36567-16348@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).