[LLVMbugs] [Bug 12544] New: clang complains when including C++11 unordered_map and unordered_set

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 13 02:45:34 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12544

             Bug #: 12544
           Summary: clang complains when including C++11 unordered_map and
                    unordered_set
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: lionel_debroux at yahoo.fr
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8382
  --> http://llvm.org/bugs/attachment.cgi?id=8382
Reduced testcase

clang++ complains about <unordered_map> and <unordered_set> from libstdc++ 4.7,
while g++ 4.6 and g++ 4.7 do not. I'm not qualified enough to determine whether
it's a deficiency in clang or a bug in g++/libstdc++ :)

Environment: Debian unstable x86_64, g++ 4.6 (default) and 4.7, libstdc++ 4.7.


$ cat t_unordered_containers.cc 
#include <string>
#include <unordered_map>
#include <unordered_set>

int main (int argc, char * argv[])
{
    // In fact, it's not necessary to declare those lines.
    // Including the header(s) is enough to trigger some error messages.
    std::unordered_map<std::string, std::string> test_map;
    std::unordered_multimap<std::string, std::string> test_multimap;
    std::unordered_set<std::string> test_set;
    std::unordered_multiset<std::string> test_multiset;

    return 0;
}



$ cat build.sh 
#!/bin/sh
g++ --version
g++ -Wall -W -O3 -std=c++0x -o t_unordered_containers_gcc
t_unordered_containers.cc
g++-4.7 --version
g++-4.7 -Wall -W -O3 -std=c++0x -o t_unordered_containers_gcc
t_unordered_containers.cc
clang++ --version
clang++ -Wall -W -O3 -std=c++0x -o t_unordered_containers_clang
t_unordered_containers.cc



$ ./build.sh 
g++ (Debian 4.6.3-3) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

t_unordered_containers.cc:5:5: warning: unused parameter ‘argc’
[-Wunused-parameter]
t_unordered_containers.cc:5:5: warning: unused parameter ‘argv’
[-Wunused-parameter]
g++-4.7 (Debian 4.7.0-3) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

t_unordered_containers.cc:5:5: warning: unused parameter ‘argc’
[-Wunused-parameter]
t_unordered_containers.cc:5:5: warning: unused parameter ‘argv’
[-Wunused-parameter]
clang version 3.1 (trunk 154660)
Target: x86_64-unknown-linux-gnu
Thread model: posix
In file included from t_unordered_containers.cc:1:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/string:41:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/char_traits.h:40:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_algobase.h:65:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:193:40:
error: member access into incomplete type 'std::pair<unsigned long, unsigned
long>'
      noexcept(noexcept(swap(first, __p.first))
                                       ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/hashtable_policy.h:285:5:
note: in instantiation of template class 'std::pair<unsigned long, unsigned
long>' requested here  
    _M_state() const
    ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:88:12:
note: definition of 'std::pair<unsigned long, unsigned long>' is not complete
until the closing '}'        
    struct pair
           ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:193:40:
error: member access into incomplete type 'std::pair<bool, unsigned long>'      
      noexcept(noexcept(swap(first, __p.first))
                                       ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/hashtable_policy.h:359:3:
note: in instantiation of template class 'std::pair<bool, unsigned long>'
requested here           
  _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
  ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:88:12:
note: definition of 'std::pair<bool, unsigned long>' is not complete until the
closing '}'                 
    struct pair
           ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:193:40:
error: member access into incomplete type 'std::pair<bool, int>'                
      noexcept(noexcept(swap(first, __p.first))
                                       ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:274:5:
note: in instantiation of template class 'std::pair<bool, int>' requested here  
    make_pair(_T1&& __x, _T2&& __y)
    ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/hashtable_policy.h:373:13:
note: in instantiation of function template specialization
'std::make_pair<bool, int>' requested  
      here
            return std::make_pair(false, 0);
                   ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:88:12:
note: definition of 'std::pair<bool, int>' is not complete until the closing
'}'                           
    struct pair
           ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:193:40:
error: member access into incomplete type 'std::pair<const
std::basic_string<char>,                       
      std::basic_string<char> >'
      noexcept(noexcept(swap(first, __p.first))
                                       ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_function.h:487:21:
note: in instantiation of template class 'std::pair<const
std::basic_string<char>,                    
      std::basic_string<char> >' requested here
                                              typename _Pair::first_type>
                                                       ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/hashtable_policy.h:531:23:
note: in instantiation of template class 'std::_Select1st<std::pair<const
std::basic_string<char>,
      std::basic_string<char> > >' requested here
           bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
                             ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/hashtable_policy.h:751:15:
note: in instantiation of default argument for '_Hashtable_ebo_helper<0,        
      std::_Select1st<std::pair<const std::basic_string<char>,
std::basic_string<char> > > >' required here
    : private _Hashtable_ebo_helper<0, _ExtractKey>,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/hashtable_policy.h:856:13:
note: in instantiation of template class
'std::__detail::_Hash_code_base<std::basic_string<char>, 
      std::pair<const std::basic_string<char>, std::basic_string<char> >,
std::_Select1st<std::pair<const std::basic_string<char>,
std::basic_string<char> > >, std::hash<string>,
      std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
true>' requested here
  : public  _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, _Hash,
            ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/hashtable.h:155:14:
note: in instantiation of template class
'std::__detail::_Hashtable_base<std::basic_string<char>,        
      std::pair<const std::basic_string<char>, std::basic_string<char> >,
std::_Select1st<std::pair<const std::basic_string<char>,
std::basic_string<char> > >,
      std::equal_to<std::basic_string<char> >, std::hash<string>,
std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>'
requested here
      public __detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal,
             ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/unordered_map.h:48:14:
note: in instantiation of template class
'std::_Hashtable<std::basic_string<char>, std::pair<const    
      std::basic_string<char>, std::basic_string<char> >,
std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char>
> >, std::_Select1st<std::pair<const
      std::basic_string<char>, std::basic_string<char> > >,
std::equal_to<std::basic_string<char> >, std::hash<string>,
std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
      std::__detail::_Prime_rehash_policy, true, false, true>' requested here
    : public _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
             ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/unordered_map.h:263:14:
note: in instantiation of template class
'std::__unordered_map<std::basic_string<char>,              
      std::basic_string<char>, std::hash<string>,
std::equal_to<std::basic_string<char> >, std::allocator<std::pair<const
std::basic_string<char>, std::basic_string<char> > >, true>' requested
      here
    : public __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
             ^
t_unordered_containers.cc:7:50: note: in instantiation of template class
'std::unordered_map<std::basic_string<char>, std::basic_string<char>,
std::hash<string>,                               
      std::equal_to<std::basic_string<char> >, std::allocator<std::pair<const
std::basic_string<char>, std::basic_string<char> > > >' requested here
    std::unordered_map<std::string, std::string> test_map;
                                                 ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:88:12:
note: definition of 'std::pair<const std::basic_string<char>,
std::basic_string<char> >' is not complete   
      until the closing '}'
    struct pair
           ^
t_unordered_containers.cc:5:15: warning: unused parameter 'argc'
[-Wunused-parameter]                                                            
int main (int argc, char * argv[])
              ^
t_unordered_containers.cc:5:28: warning: unused parameter 'argv'
[-Wunused-parameter]                                                            
int main (int argc, char * argv[])
                           ^
2 warnings and 4 errors generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list