Consider the following code:
#include <iostream> #include <math.h> double log(double) { return 42; } int main() { std::cout << log(1) << std::endl; }
During the build of the debug version, all used compilers (msvc, gcc, clang) print 42.
42
But when I try to build (and run) in release mode, I got:
error C2169: 'log' : intrinsic function, cannot be defined
0
Why are the debug / debug results different for the same compiler?
Why were there different results for different compilers in release mode?
You define a function that is already declared in <math.h>with an external connection.
<math.h>
C11, Β§7.12.6.7:
#include <math.h> double log(double x);
Β§7.1.2:
.
[extern.names]/3:
Standard C, "C" link std, .
std
[reserved.names]/2 undefined; , , , .
, (17.6.1.2.4):
++ ( , C) (3.3.6) std. , std - (7.3.3).
, log() math.h ( cmath) std . ( libstd++ gcc), log(1) , std::log(). clang, -, .
log()
math.h
cmath
log(1)
std::log()
template <typename T> double log(T x);
, int, clang . ( , coliru clang, ).