no bounds checking in basic_string::operator[] despite compilation macro
Hello,
Despite setting the _RWSTD_BOUNDS_CHECKING macro with CC 5.6 (Patch 117549-06) on Solaris 8, we don't get any exception when doing array bounds write on strings. This is all the more confusing as setting this macro works for vector::operator[] and the source code in SUNWspro/prod/include/CC/Cstd/string seems simple :
template <class charT, class traits , class Allocator >
inline _TYPENAME basic_string<charT, traits,Allocator>::const_reference
basic_string<charT, traits, Allocator>::operator[] (size_type pos) const
{
#ifdef _RWSTD_BOUNDS_CHECKING
_RWSTD_THROW(pos > size(), out_of_range,
__RWSTD::except_msg_string(__RWSTD::__rwse_PosBeyondEndOfString,
"basic_string::operator[](size_t) const", pos,size()).msgstr());
#endif
return __data_.data()[pos];
}
However, on a test case like hereunder, we get no exception despite the -D_RWSTD_BOUNDS_CHECKING option :
#include <string>
using std::string;
int main()
{
string a = "0123";
a[4] = '4';
}

