https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63780
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- This is nothing to do with libstdc++: int main() { int n; double x = 3419, m = 360; double y = __builtin_remainder(x, m); double z = __builtin_remquo(x, m, &n); __builtin_printf("result %.0f %.0f %d\n", y, z, n); } With optimisation GCC inlines its own definitions that give the right answer, so this looks like a glibc bug.