This code does not compile on gcc 3.4.4. Should it?
Thanks for your help,
Chris
//=============== =
#include <set>
int main()
{
std::set<const int> s;
s.insert(3);
return 0;
}
//=============== =
[cstankevitz@mag gie temp]$ g++ --version
g++ (GCC) 3.4.4 20050721 (Red Hat 3.4.4-2)
Copyright (C) 2004 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.
[cstankevitz@mag gie temp]$ g++ temp.cpp
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/ext/new_all
ocator.h: In instantiation of `__gnu_cxx::new _allocator<cons t int>':
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/alloca
tor.h:81: instantiated from `std::allocator <const int>'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:329: instantiated from `std::_Rb_tree< const int, const int,
std::_Identit
y<const int>, std::less<const int>, std::allocator< const int> >'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_se
t.h:127: instantiated from `std::set<const int, std::less<const int>,
std::all
ocator<const int> >'
temp.cpp:5: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/ext/new_all
ocator.h:75: error: `const _Tp*
__gnu_cxx::new_ allocator<_Tp>: :address(const _Tp
&) const [with _Tp = const int]' and `_Tp*
__gnu_cxx::new_ allocator<_Tp>: :addres
s(_Tp&) const [with _Tp = const int]' cannot be overloaded
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_fu
nction.h: In instantiation of `std::_Identity <const int>':
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:871: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Val, _Key
OfValue, _Compare, _Alloc>::iterat or, bool> std::_Rb_tree<_ Key, _Val,
_KeyOfValu
e, _Compare, _Alloc>::insert _unique(const _Val&) [with _Key = const
int, _Val =
const int, _KeyOfValue = std::_Identity< const int>, _Compare =
std::less<const i
nt>, _Alloc = std::allocator< const int>]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_se
t.h:314: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Key, std::
_Identity<_Key> , _Compare, _Alloc>::const_ iterator, bool>
std::set<_Key, _Compar
e, _Alloc>::insert (const _Key&) [with _Key = const int, _Compare =
std::less<con
st int>, _Alloc = std::allocator< const int>]'
temp.cpp:7: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_fu
nction.h:538: error: `const _Tp& std::_Identity< _Tp>::operator( )(const
_Tp&) con
st [with _Tp = const int]' and `_Tp&
std::_Identity< _Tp>::operator( )(_Tp&) const
[with _Tp = const int]' cannot be overloaded
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_co
nstruct.h: In function `void std::_Construct (_T1*, const _T2&) [with
_T1 = const
int, _T2 = int]':
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:367: instantiated from `std::_Rb_tree_ node<_Val>*
std::_Rb_tree<_ Key, _Va
l, _KeyOfValue, _Compare, _Alloc>::_M_cre ate_node(const _Val&) [with
_Key = cons
t int, _Val = const int, _KeyOfValue = std::_Identity< const int>,
_Compare = std
::less<const int>, _Alloc = std::allocator< const int>]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:783: instantiated from `typename std::_Rb_tree<_ Key, _Val,
_KeyOfValue, _
Compare, _Alloc>::iterat or std::_Rb_tree<_ Key, _Val, _KeyOfValue,
_Compare, _All
oc>::_M_insert( std::_Rb_tree_n ode_base*, std::_Rb_tree_n ode_base*,
const _Val&)
[with _Key = const int, _Val = const int, _KeyOfValue =
std::_Identity< const int[color=blue]
>, _Compare = std::less<const int>, _Alloc = std::allocator< const int>]'[/color]
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:877: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Val, _Key
OfValue, _Compare, _Alloc>::iterat or, bool> std::_Rb_tree<_ Key, _Val,
_KeyOfValu
e, _Compare, _Alloc>::insert _unique(const _Val&) [with _Key = const
int, _Val =
const int, _KeyOfValue = std::_Identity< const int>, _Compare =
std::less<const i
nt>, _Alloc = std::allocator< const int>]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_se
t.h:314: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Key, std::
_Identity<_Key> , _Compare, _Alloc>::const_ iterator, bool>
std::set<_Key, _Compar
e, _Alloc>::insert (const _Key&) [with _Key = const int, _Compare =
std::less<con
st int>, _Alloc = std::allocator< const int>]'
temp.cpp:7: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_co
nstruct.h:81: error: invalid static_cast from type `const int*' to type
`void*'
Thanks for your help,
Chris
//=============== =
#include <set>
int main()
{
std::set<const int> s;
s.insert(3);
return 0;
}
//=============== =
[cstankevitz@mag gie temp]$ g++ --version
g++ (GCC) 3.4.4 20050721 (Red Hat 3.4.4-2)
Copyright (C) 2004 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.
[cstankevitz@mag gie temp]$ g++ temp.cpp
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/ext/new_all
ocator.h: In instantiation of `__gnu_cxx::new _allocator<cons t int>':
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/alloca
tor.h:81: instantiated from `std::allocator <const int>'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:329: instantiated from `std::_Rb_tree< const int, const int,
std::_Identit
y<const int>, std::less<const int>, std::allocator< const int> >'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_se
t.h:127: instantiated from `std::set<const int, std::less<const int>,
std::all
ocator<const int> >'
temp.cpp:5: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/ext/new_all
ocator.h:75: error: `const _Tp*
__gnu_cxx::new_ allocator<_Tp>: :address(const _Tp
&) const [with _Tp = const int]' and `_Tp*
__gnu_cxx::new_ allocator<_Tp>: :addres
s(_Tp&) const [with _Tp = const int]' cannot be overloaded
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_fu
nction.h: In instantiation of `std::_Identity <const int>':
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:871: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Val, _Key
OfValue, _Compare, _Alloc>::iterat or, bool> std::_Rb_tree<_ Key, _Val,
_KeyOfValu
e, _Compare, _Alloc>::insert _unique(const _Val&) [with _Key = const
int, _Val =
const int, _KeyOfValue = std::_Identity< const int>, _Compare =
std::less<const i
nt>, _Alloc = std::allocator< const int>]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_se
t.h:314: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Key, std::
_Identity<_Key> , _Compare, _Alloc>::const_ iterator, bool>
std::set<_Key, _Compar
e, _Alloc>::insert (const _Key&) [with _Key = const int, _Compare =
std::less<con
st int>, _Alloc = std::allocator< const int>]'
temp.cpp:7: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_fu
nction.h:538: error: `const _Tp& std::_Identity< _Tp>::operator( )(const
_Tp&) con
st [with _Tp = const int]' and `_Tp&
std::_Identity< _Tp>::operator( )(_Tp&) const
[with _Tp = const int]' cannot be overloaded
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_co
nstruct.h: In function `void std::_Construct (_T1*, const _T2&) [with
_T1 = const
int, _T2 = int]':
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:367: instantiated from `std::_Rb_tree_ node<_Val>*
std::_Rb_tree<_ Key, _Va
l, _KeyOfValue, _Compare, _Alloc>::_M_cre ate_node(const _Val&) [with
_Key = cons
t int, _Val = const int, _KeyOfValue = std::_Identity< const int>,
_Compare = std
::less<const int>, _Alloc = std::allocator< const int>]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:783: instantiated from `typename std::_Rb_tree<_ Key, _Val,
_KeyOfValue, _
Compare, _Alloc>::iterat or std::_Rb_tree<_ Key, _Val, _KeyOfValue,
_Compare, _All
oc>::_M_insert( std::_Rb_tree_n ode_base*, std::_Rb_tree_n ode_base*,
const _Val&)
[with _Key = const int, _Val = const int, _KeyOfValue =
std::_Identity< const int[color=blue]
>, _Compare = std::less<const int>, _Alloc = std::allocator< const int>]'[/color]
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_tr
ee.h:877: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Val, _Key
OfValue, _Compare, _Alloc>::iterat or, bool> std::_Rb_tree<_ Key, _Val,
_KeyOfValu
e, _Compare, _Alloc>::insert _unique(const _Val&) [with _Key = const
int, _Val =
const int, _KeyOfValue = std::_Identity< const int>, _Compare =
std::less<const i
nt>, _Alloc = std::allocator< const int>]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_se
t.h:314: instantiated from `std::pair<type name std::_Rb_tree<_ Key,
_Key, std::
_Identity<_Key> , _Compare, _Alloc>::const_ iterator, bool>
std::set<_Key, _Compar
e, _Alloc>::insert (const _Key&) [with _Key = const int, _Compare =
std::less<con
st int>, _Alloc = std::allocator< const int>]'
temp.cpp:7: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_co
nstruct.h:81: error: invalid static_cast from type `const int*' to type
`void*'
Comment