4 ms·
Here gcc (9.4.0) throws a warning if the first declaration is commented and the second one uncommented, but it prints "0". Care to explain why?
by marcodiego 4y ago
Here gcc (9.4.0) throws a warning if the first declaration is commented and the second one uncommented, but it prints "0". Care to explain why?
- WalterBright 4y agoBecause foo() gets implicitly declared as accepting int arguments, when it actually accepts a double. The double bits interpreted as an int are 0.
- edflsafoiewq 4y agoOn x64, foo(double) expects its argument in xmm0, but foo(int) expects it in rdi. So the 3 passed in rdi is ignored and it operates on whatever happened to be in xmm0.
- WalterBright 4y agoYes, you're right. Thanks for the correction. I was thinking of the Windows C ABI.