Parameters of a Function Run from Command Window Are Corrupted

ID Number: Q71834

2.x 3.00 3.10 3.11 3.14 | 2.x 3.00 3.10 3.11 3.12 3.50

MS-DOS | OS/2

buglist3.10 buglist3.11 buglist3.12 buglist3.14 buglist3.50

Summary:

When invoking a function from the command window in CodeView, the

parameters may be corrupted if the function has been compiled in small

or medium memory model.

More Information:

Any C function that has been compiled with CodeView information (/Zi)

can be called from the command window. However, in the example below,

the third parameter returns an incorrect value when invoked with the

following statement:

?test("one", "two", 3)

The return value from the function, which should be displayed in the

command window, is 3; however, the returned value is not 3, and its

value is inconsistent. If all of the parameters are either integers or

string constants (rather than a combination) then the values are

returned correctly.

The following two workarounds may be used to avoid this problem:

1. Compile the program in compact, large, or huge memory model.

-or-

2. Declare string constants within the program and then use those to

call the function. For example, if you declared the variables

char * a = "one", * b = "two";

then you could invoke the function with the following command:

?test( a, b, 3 )

Microsoft has confirmed this to be a problem in CodeView versions 2.2,

2.3, 2.35, 3.0, 3.1, 3.11, 3.12, 3.14 and 3.5. We are researching this

problem and will post new information here as it becomes available.

Sample Code

-----------

/* Compile options needed: /AS (or /AM) /Zi

*/

#include <stdio.h>

int test( char * s1, char * s2, int a3)

{

return( a3 );

}

void main(void)

{

int c;

c = test("one", "two", 3 );

printf("This should be a three: %d", c);

}

Additional reference words: buglist3.00 buglist2.35 buglist2.30

buglist2.20 2.20 2.30 2.30 2.35 3.00 3.10 3.11 3.12 3.14 3.50