[comp.os.msdos.programmer] Paramters of type float getting corrupted in Microsoft C 5.1. HELP !!!

elee24@castle.ed.ac.uk (H Bruce) (10/31/90)

I am having a problem with Microsoft C (V 5.1).

When I pass a parameter of type float (by value) to a function, by the time
it is read from the stack by the function it is corrupted.
The corrupted value is something very small (eg X.XXXXe-XXX) and varies
depending on the parameter.

The program comprises 2000 lines of code in 7 modules producing a 90K EXE file.
I am using the the large memory model.
When I extract the offending part of the program and run it independently,
the problem vanishes. 

This is happening in several functions. If I get around it by not passing
parameters the problem manifests itself somewhere else.
I have stack checking enabled.
I have allocated 8K for the stack and there is over 1K free.
(The stack size may sound a bit large but I pass some large structures as
paramters.)


Does anyone know what is is happening?
How can I look at the stack in codeview ?
How can I stop execution in codeview when the parameter is corrupted ?
(This would have to be at assembly level I think ...... yeeeuuuch)

Thanks in desperation,

Henry Bruce.

mmshah@athena.mit.edu (Milan M Shah) (11/01/90)

WRT float parameters getting corrupted.

I ran into this problem once, and it is a known bug with MSC 5.1. I can't
remember the exact details - I vaguely recall that it had something to do
with either the float parameter being on an odd byte boundary, or being
part of a struct that was more than 16 bytes long, or maybe both.

I do, however, remember the workaround he suggested - pass a pointer to
the float or struct instead. For exact details, call Microsoft.

If this is too vague, I can probably dig up some code that shows where
the problem occured and how it was 'fixed'

Hope this helps.

Milan
.