Bug 54144 - [4.6 Regression] With -std=c++0x certain incorrect arguments to map.insert cause gcc crash
Summary: [4.6 Regression] With -std=c++0x certain incorrect arguments to map.insert ca...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.3
: P3 minor
Target Milestone: 4.6.4
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2012-07-31 17:52 UTC by Greg Hale
Modified: 2012-10-04 15:52 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.5.3, 4.7.1, 4.8.0
Known to fail: 4.6.3
Last reconfirmed: 2012-07-31 00:00:00


Attachments
Preprocessor output (82.85 KB, application/octet-stream)
2012-07-31 17:52 UTC, Greg Hale
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Hale 2012-07-31 17:52:07 UTC
Created attachment 27910 [details]
Preprocessor output

This incorrect code causes gcc to crash with a message ending:

...
/usr/include/c++/4.6/bits/stl_tree.h:1335: confused by earlier errors, bailing out

(full message pasted below)


#include <map>
#include <iostream>

int main(int argc, char *argv[]){

  std::map <std::string,std::string> a_map;
  a_map.insert("Hello","Hi");

}

Built with:
g++ -D__STDC_LIMIT_MACROS -std=c++0x -o test test2.cpp

System is:  i386 Ubuntu 12.04.  g++ pre-built in package build-essential.  gcc4.4 package is also installed on this machine.

Fixing the code is the work-around of course.  Just submitting this (my first ever) bug report in case it is useful.  

Preprocessor output is attached.

Full error message:

greghale@jellyroll:~/arte-ephys/src/test/convert_config_to_proto$ ./build.sh
In file included from /usr/include/c++/4.6/map:60:0,
                 from test2.cpp:1:
/usr/include/c++/4.6/bits/stl_tree.h: In member function ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique_(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, _Arg&&) [with _Arg = const char&, _Key = std::basic_string<char>, _Val = std::pair<const std::basic_string<char>, std::basic_string<char> >, _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, std::basic_string<char> > >, _Compare = std::less<std::basic_string<char> >, _Alloc = std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char> > >, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, std::basic_string<char> > >, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<const std::basic_string<char>, std::basic_string<char> > >]’:
/usr/include/c++/4.6/bits/stl_tree.h:1466:4:   instantiated from ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_II, _II) [with _InputIterator = const char*, _Key = std::basic_string<char>, _Val = std::pair<const std::basic_string<char>, std::basic_string<char> >, _KeyOfValue = std::_Select1st<std::pair<const std::basic_string<char>, std::basic_string<char> > >, _Compare = std::less<std::basic_string<char> >, _Alloc = std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char> > >]’
/usr/include/c++/4.6/bits/stl_map.h:594:11:   instantiated from ‘void std::map<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = const char*, _Key = std::basic_string<char>, _Tp = std::basic_string<char>, _Compare = std::less<std::basic_string<char> >, _Alloc = std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char> > >]’
test2.cpp:7:28:   instantiated from here
/usr/include/c++/4.6/bits/stl_tree.h:1335:4: error: no match for call to ‘(std::_Select1st<std::pair<const std::basic_string<char>, std::basic_string<char> > >) (const char&)’
/usr/include/c++/4.6/bits/stl_function.h:486:12: note: candidates are:
/usr/include/c++/4.6/bits/stl_function.h:490:7: note: typename _Pair::first_type& std::_Select1st<_Pair>::operator()(_Pair&) const [with _Pair = std::pair<const std::basic_string<char>, std::basic_string<char> >, typename _Pair::first_type = const std::basic_string<char>]
/usr/include/c++/4.6/bits/stl_function.h:490:7: note:   no known conversion for argument 1 from ‘const char’ to ‘std::pair<const std::basic_string<char>, std::basic_string<char> >&’
/usr/include/c++/4.6/bits/stl_function.h:494:7: note: const typename _Pair::first_type& std::_Select1st<_Pair>::operator()(const _Pair&) const [with _Pair = std::pair<const std::basic_string<char>, std::basic_string<char> >, typename _Pair::first_type = const std::basic_string<char>]
/usr/include/c++/4.6/bits/stl_function.h:494:7: note:   no known conversion for argument 1 from ‘const char’ to ‘const std::pair<const std::basic_string<char>, std::basic_string<char> >&’

/usr/include/c++/4.6/bits/stl_tree.h:1335: confused by earlier errors, bailing out
Preprocessed source stored into /tmp/ccK6HImL.out file, please attach this to your bugreport.

Thanks for gcc :)
Comment 1 Jonathan Wakely 2012-07-31 18:02:09 UTC
seems to be already fixed in the 4.7 branch and on trunk
Comment 2 Paolo Carlini 2012-10-04 15:52:20 UTC
Confirmed already fixed.