Q50251: /Ol Causes Constant Overflow Warnings c4057 c4056
Article: Q50251
Product(s): See article
Version(s): 5.00 5.10 | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 17-JUL-1990
The following small program, when compiled with loop optimization
(/Ol), produces the following warnings on the auto-decrement statement
in the second for loop:
warning C4057: overflow in constant multiplication
warning C4056: overflow in constant arithmetic
The warnings occur as a side effect of the optimization of the second
loop. Because the second loop has no functional value, it is optimized
to the loop-terminating conditions by the compiler. The warnings
appear to be benign; the program runs as expected. It is recommended,
however, that if you encounter these errors you generate an assembly
listing of the code and check the loop for correctness. These warnings
do not occur in any version of QuickC, QCL, or QuickAssembler.
Sample Code
-----------
#include<stdio.h>
void main(void)
{
unsigned char *p1,
*start,
i,
j;
start = "abcdefgh";
for(i = 0, p1 = &start[7]; i < 7; i++){
p1--;
j = *p1;
}
for(i = 0, p1 = &start[7]; i < 7; i++){
p1--;
}
}
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.