Seen on x86_64-linux and ia64-linux. g++ -std=gnu++98 -c -g -DIN_GCC -fno-strict-aliasing -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -DHAVE_CONFIG_H -DGENERATOR_FILE -fno-PIE -I. -Ibuild -I/gcc/spec/sb-vangelis-head-64/gcc/gcc -I/gcc/spec/sb-vangelis-head-64/gcc/gcc/build -I/gcc/spec/sb-vangelis-head-64/gcc/gcc/../include -I/gcc/spec/sb-vangelis-head-64/gcc/gcc/../libcpp/include \ -o build/vec.o /gcc/spec/sb-vangelis-head-64/gcc/gcc/vec.c /usr/include/c++/4.1.2/bits/stl_pair.h: In instantiation of 'std::pair<mem_location* const&, vec_usage*&>': /gcc/spec/sb-vangelis-head-64/gcc/gcc/mem-stats.h:597: instantiated from 'typename mem_alloc_description<T>::mem_list_t* mem_alloc_description<T>::get_list(mem_alloc_origin, unsigned int*, int (*)(const void*, const void*)) [with T = vec_usage]' /gcc/spec/sb-vangelis-head-64/gcc/gcc/mem-stats.h:637: instantiated from 'void mem_alloc_description<T>::dump(mem_alloc_origin, int (*)(const void*, const void*)) [with T = vec_usage]' /gcc/spec/sb-vangelis-head-64/gcc/gcc/vec.c:175: instantiated from here /usr/include/c++/4.1.2/bits/stl_pair.h:84: error: forming reference to reference type 'vec_usage*&' /gcc/spec/sb-vangelis-head-64/gcc/gcc/hash-map.h: In member function 'std::pair<const typename Traits::key_type&, Value&> hash_map< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3> >::iterator::operator*() [with KeyId = mem_alloc_description<vec_usage>::mem_location_hash, Value = vec_usage*, Traits = simple_hashmap_traits<default_hash_traits<mem_alloc_description<vec_usage>::mem_location_hash>, vec_usage*>]': /gcc/spec/sb-vangelis-head-64/gcc/gcc/mem-stats.h:597: instantiated from 'typename mem_alloc_description<T>::mem_list_t* mem_alloc_description<T>::get_list(mem_alloc_origin, unsigned int*, int (*)(const void*, const void*)) [with T = vec_usage]' /gcc/spec/sb-vangelis-head-64/gcc/gcc/mem-stats.h:637: instantiated from 'void mem_alloc_description<T>::dump(mem_alloc_origin, int (*)(const void*, const void*)) [with T = vec_usage]' /gcc/spec/sb-vangelis-head-64/gcc/gcc/vec.c:175: instantiated from here /gcc/spec/sb-vangelis-head-64/gcc/gcc/hash-map.h:229: error: no matching function for call to 'std::pair<mem_location* const&, vec_usage*&>::pair(mem_location*&, vec_usage*&)' /usr/include/c++/4.1.2/bits/stl_pair.h:80: note: candidates are: std::pair<_T1, _T2>::pair() [with _T1 = mem_location* const&, _T2 = vec_usage*&] /usr/include/c++/4.1.2/bits/stl_pair.h:69: note: std::pair<mem_location* const&, vec_usage*&>::pair(const std::pair<mem_location* const&, vec_usage*&>&) make[3]: *** [build/vec.o] Error 1
Regressed between r262525 (good) and r262545 (bad). Thus probably caused by r262539. /usr/include/c++/4.1.2/bits/stl_pair.h:84 is /** Two objects may be passed to a @c pair constructor to be copied. */ pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) { } so it somehow doesn't like _T1 == vec_usage*& here I added with std::pair<const Key&, Value&> operator* () { hash_entry &e = *m_iter; return std::pair<const Key&, Value&> (e.m_key, e.m_value); } C++ folks?
Created attachment 44466 [details] preprocessed source For reference, here's preprocessed source.
The code is well-formed according to http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#106 but that doesn't seem to be implemented in GCC 4.1.2 template<typename T> struct X { X(T&) { } }; X<int&> f(int& i) { return X<int&>(i); } <source>: In instantiation of 'X<int&>': <source>:6: instantiated from here <source>:3: error: forming reference to reference type 'int&'
See PR 7412 "Fixed on mainline for GCC 4.3.0. DR 106 is implemented for C++0x mode and for non-strict C++98 mode."
So somehow mem_alloc_description<vec_usage>::mem_map_t which then is hash_map <mem_location_hash, vec_usage *> ends up with this reference type. But I can't figure out how :/ It in the end uses pointer_hash which has value/compare type of T * again with T == mem_location. hash_entry of the hash-map should have Value == vec_usage *, so I'm confused as to where the reference appears. ISTR figuring the default hash_map<> template resolution is a bit tricky.
(In reply to Richard Biener from comment #5) > ISTR figuring the default hash_map<> template resolution is a bit tricky. ISTR thinking it was rather overcomplicated.
Iain confirmed this on IRC for darwin
https://godbolt.org/z/DcywdN Apparently std::pair with reference template arguments (either of them) just doesn't work in 4.1 at all because of that missing CWG. So, do we require that hash_map's iterator's operator * returns std::pair, or can it return some other class that has first and second members?
Created attachment 45000 [details] gcc9-pr86739.patch This works for me (well, make in gcc/ with recent gcc still builds and the preprocessed source from this PR with those tweaks compiles with GCC 4.1).
Created attachment 45001 [details] gcc9-pr86739-2.patch Variant patch if the conversion operator would not be acceptable.
Author: jakub Date: Wed Nov 14 16:43:38 2018 New Revision: 266152 URL: https://gcc.gnu.org/viewcvs?rev=266152&root=gcc&view=rev Log: PR bootstrap/86739 * hash-map.h (hash_map::iterator::reference_pair): New class. (hash_map::iterator::operator*): Return it rather than std::pair. Modified: trunk/gcc/ChangeLog trunk/gcc/hash-map.h
Jakub: Can the bug be marked as resolved?
I haven't tested such a bootstrap, but I hope it is ok.