C 5.10 May Generate Incorrect Code for Intrinsic memset()

ID Number: Q30448

5.10

MS-DOS

buglist5.10 fixlist6.00

Summary:

The C version 5.10 compiler produces incorrect code for the intrinsic

version of the memset() function in some situations.

The code for the sample program below demonstrates this problem when

compiled with the options /AL and /Oi. The generated code moves the

offset of the array dummy into the di register, then uses the di

register as the value for the lr variable. You can work around the

problem by declaring the lr variable as an integer rather than a

register variable.

Microsoft has confirmed this to be a problem in C version 5.10. This

problem was corrected in C version 6.00.

Sample Code

-----------

char dummy[10];

void foo()

{

register int l,lr, r, i;

l = 100;

memset(&dummy[1], lr, i++);

}