https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116331
--- Comment #6 from Carl Dehlin <carl at dehlin dot com> --- Thanks Jakub for your explanation. Indeed, the following program runs fine and confirms what you just said. Inspecting the assembly shows can both std::cos and __builtin_cos are substituted to a library call when the input is not known at compile time #include <cmath> #include <cassert> #include <cstdio> int main() { double x; if (!scanf("%lf", &x)) { return 1; } const double y = std::cos(x); const auto f = [x,y] { const double z = __builtin_cos(x); __builtin_printf("%a\n%a\n", y, z); return y == z; }; assert(f()); }