Предупреждение C ++ GCC4.4: индекс массива находится выше границ массива
Я недавно обновился до GCC 4.4 (MinGW TDM build), и теперь следующий код выдает следующее предупреждение:
In member function 'void Console::print(const std::string&)':
warning: array subscript is above array bounds
Вот код:
void Console::print( const std::string& str ) {
std::string newLine( str );
if( newLine.size() > MAX_LINE_LENGTH ) {
sf::Uint32 stringSize = newLine.size();
for( sf::Uint32 insertPos = MAX_LINE_LENGTH;
insertPos < stringSize; insertPos += MAX_LINE_LENGTH ) {
newLine.insert( insertPos, "\n" );
}
}
StringList tokens;
boost::split( tokens, newLine, boost::is_any_of("\n") );
for( StringList::iterator it = tokens.begin();
it != tokens.end(); ++it ) {
addLine( *it );
}
}
Есть идеи?
Это оптимизации, которые делают это ...
Также кажется, что эта строка вызывает это:
boost::split( tokens, newLine, boost::is_any_of("\n") );
Ах да, я нашел это, это аргумент для boost :: is_any_of (), оборачивая его в конструктор string (), предупреждение исчезает, спасибо всем за помощь :)
boost::split( tokens, newLine, boost::is_any_of( string( "\n" ) ) );