I have the following simple code:
#include <cmath>
struct init_sin
{
typedef double type;
static constexpr type value(int index) {
return 3*std::pow(std::sin(index * 2.0 * 3.1415 / 20.0),1.999);
}
};
int main(){
static double VALUE = init_sin::value(10);
double VALUE_NONSTAT = 3*std::pow(std::sin(10 * 2.0 * 3.1415 / 20.0),1.999);
return int(VALUE_NONSTAT);
}
I would like to find out what the meaning of the assembler code is of this given piece.
Here the link to the assembly: http://pastebin.com/211AfSYh
I thought that VALUE is compile time computed and directly as value in the assembler code
Which should be in this line if I am not mistaken:
33 .size main, .-main
34 .data
35 .align 8
36 .type _ZZ4mainE5VALUE, @object
GAS LISTING /tmp/ccbPDNK8.s page 2
37 .size _ZZ4mainE5VALUE, 8
38 _ZZ4mainE5VALUE:
39 0000 15143B78 .long 2017137685
40 0004 45E95B3E .long 1046210885
- Why are there two values with
.long? And why are the types long? (its a double?, maybe in assembler there is only long. - Does that mean that the value of
VALUEwas compile time generated - Where is the result for VALUE_NON_STATIC? This should be computed during run-time right? I cannot quite see where?
Thanks a lot!