issue with each specifically for x86

ketmar ketmar at ketmar.no-ip.org
Wed Mar 7 20:56:04 UTC 2018


H. S. Teoh wrote:

> On Wed, Mar 07, 2018 at 10:21:42PM +0200, ketmar via Digitalmars-d-learn 
> wrote:
> [...]
>> it looks like ignoring `double` result causes FPU stack imbalance
>> ('cause compiler doesn't insert "FPU pop" instruction), and that
>> affects the computations.
>> on 64 bit it doesn't matter, 'cause no FPU is used there.
>> the fix prolly should be easy: just emit "FPU pop" if function result
>> is ignored. codegen should have this info at hand, i believe.
>
> Nice catch!  Is there a bug filed for this yet?  If not, it should be.

btw, this is specific to `cast(void)`. if you'll remove the cast, or do 
something like `cast(void)(pred(i)+42);`, the bug won't be there. so it 
looks like it is not a codegen bug after all, but glue layer. the codegen 
is correctly dropping the result without `cast(void)` (`fstp   %st(0)` is 
inserted in `main`), but cannot do that if return type information is stripped.

so it looks that glue layer should not strip return type info.


More information about the Digitalmars-d-learn mailing list