c++ - Optimiser bug ?
- Carlos Smith (60/60) Dec 19 2010 Here is a small program compiled with:
Here is a small program compiled with:
Digital Mars C/C++ Compiler Version 8.52.5n
I think there is a bug introduced by the optimiser.
Am I right ?
extern unsigned long D2UL(double);
unsigned long d2ul()
{
union
{ double d;
struct { unsigned long a,b; } S;
} U;
U.S.a = _EDX;
U.S.b = _EAX;
return D2UL(U.d);
}
#pragma alias("__DBLULNG ","_d2ul")
void main()
{
double d;
unsigned long ul;
d=(double)-1;
ul=d;
}
/*
* compiled with: dmc -o -c -cod u5 (optimised)
*/
_d2ul:
sub ESP,01Ch
mov 4[ESP],EDX
mov 8[ESP],EAX
// pushing the same piece 2 times ?
push dword ptr 8[ESP]
push dword ptr 8[ESP]
call near ptr _D2UL
add ESP,024h
ret
/*
* compiled with: dmc -c -cod u5 (no optimisation)
*/
_d2ul:
enter 8,0
mov -8[EBP],EDX
mov -4[EBP],EAX
// pushing 2 pieces
push dword ptr -4[EBP]
push dword ptr -8[EBP]
call near ptr _D2UL
add ESP,8
leave
ret
begin 666 u5.c
M/2!?1418.PT*"54N4RYB(#T 7T5!6#L-
M;VED(&UA:6XH*0T*>PT*"61O=6)L92!D.PT*"75N<VEG;F5D(&QO;F< =6P[
`
end
Dec 19 2010








"Carlos Smith" <carlos.smith33 gmail.com>