wrong unprototyped calls with optimization in amd64 linux suncc 12
In C modus it doesn't seem to handle an unprototyped function call
like a varargs (...) call, but like (void). The code doesn't initialize eax to zero which is required for varargs calls in the amd64 ABI. icc and gcc
both get this correct.
This could be potentially deadly when calling a gcc generated
varargs function this way. gcc uses the eax input for an computed
jump to save the right number of SSE registers. If there is random
junk in eax it will jump to a random place which is hard to debug.
This seems to only happen when optimization is enabled, without
optimization the code is correct.
Test case:
f()
{
f2();
f2();
return 1; // prevent tail call
}
generates with -O2
callf2;/ line : 4
callf2;/ line : 5
(no eax initialization)
without -O it gives correctly:
movl$0, %eax
callf2
/ Line 5
movl$0, %eax
callf2

