Странности GCC
Привет всем,
кто-нибудь может объяснить странности в поведении gcc? правда он немного староват, но всё же =)
Ситуация такая:
user@localhost ~/torrents/crawler/sites $ cat test.cpp
#include <string>
#include <iostream>
int main() {
std::string downloads = "13,678";
downloads.erase(std::remove(downloads.be gin(), downloads.end(), ','), downloads.end());
std::cout << downloads << std::endl;
}
user@localhost ~/torrents/crawler/sites $ g++ test.cpp
user@localhost ~/torrents/crawler/sites $ ./a.out
Segmentation fault
user@localhost ~/torrents/crawler/sites $ g++ test.cpp -O
user@localhost ~/torrents/crawler/sites $ ./a.out
13678
user@localhost ~/torrents/crawler/sites $ g++ --version
g++ (GCC) 3.4.6 (Gentoo Hardened 3.4.6-r2 p1.5, ssp-3.4.6-1.0, pie-8.7.10)
Copyright (C) 2006 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.
update решением проблемы в общем-то оказалось обновление gcc до 4.1.2. Извиняюсь за беспокойство, я мог бы сразу догадаться, что это баг gcc такой и надо обновиться)
кто-нибудь может объяснить странности в поведении gcc? правда он немного староват, но всё же =)
Ситуация такая:
user@localhost ~/torrents/crawler/sites $ cat test.cpp
#include <string>
#include <iostream>
int main() {
std::string downloads = "13,678";
downloads.erase(std::remove(downloads.be
std::cout << downloads << std::endl;
}
user@localhost ~/torrents/crawler/sites $ g++ test.cpp
user@localhost ~/torrents/crawler/sites $ ./a.out
Segmentation fault
user@localhost ~/torrents/crawler/sites $ g++ test.cpp -O
user@localhost ~/torrents/crawler/sites $ ./a.out
13678
user@localhost ~/torrents/crawler/sites $ g++ --version
g++ (GCC) 3.4.6 (Gentoo Hardened 3.4.6-r2 p1.5, ssp-3.4.6-1.0, pie-8.7.10)
Copyright (C) 2006 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.
