Compare this trivial program compiled with -DVBOOL and not: #include <vector>
int main() { unsigned N = 100000; for (unsigned i = 0; i < 100000; ++i) { #if VBOOL std::vector<bool> V; V.resize(N); #else char *X = new char[(N+7)/8]; memset(X, 0, (N+7)/8); delete[] X; #endif } } Compiled at -O3 on a 2.5Ghz G5, the -DVBOOL version takes 47.951s, the memset version takes 0.053s. This spends all of it's time in std::fill, inserting one bit at a time into the vector when it resizes. This is bad and stuff. -Chris -- Summary: vector<bool> is extremely slow (900x slower than it should be) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sabre at nondot dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28587