$ cat test.cc #include <math.h> #include <algorithm> bool foo(double d) { return isfinite(d); } $ ~/opensource/gcc/git/install/bin/g++ -c test.cc $ ~/opensource/gcc/git/install/bin/g++ -c test.cc -std=gnu++0x test.cc: In function ‘bool foo(double)’: test.cc:5:20: error: ‘isfinite’ was not declared in this scope test.cc:5:20: note: suggested alternative: .../include/c++/4.7.0/cmath:528:21: note: ‘std::isfinite’ $ This is a regression since gcc-4.4: $ g++-4.4 -c test.cc -std=gnu++0x $ It happens because <stl_algo.h> includes <random> in C++0x mode only, and <random> includes <cmath>, which #undefs all the C99 math functions that <math.h> defined, without 'using' the std functions back into the global namespace. As far as I can tell, [depr.c.headers] says that <math.h> puts the <cmath> names into the global namespace, and it doesn't allow a later include of <cmath> to take them back out. [depr.c.headers] also allows <cmath> to unconditionally put its declarations and definitions into the global namespace, which is what I'd propose as a fix.
FWIW, the path from algorithm->cmath appears to have been introduced in gcc-4.5.
. *** This bug has been marked as a duplicate of bug 14608 ***