INF: Different Warnings Appear Using Different Optimizations

ID Number: Q67078

6.00 6.00a 6.00ax 7.00 | 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 6.0, 6.0a, 6.0ax, and C/C++ version 7.0,

different warning messages can appear from separate compilations of

the same code when different optimizations are used. This is normal

and occurs because some warnings are found only while optimizing.

If the sample code below is compiled with /W4 (all warnings) and the

/Os optimization (optimize for space), no warnings are found. However,

when the code is compiled with /W4 and /Osle (optimize for size, loop,

and global-register allocation), the following warning is generated:

file.c(7) : warning C4202: unreachable code

There are several other optimizations and code examples that will

exhibit this type of behavior. Once again, this is normal and serves

to notify the developer that there MAY be a problem.

Sample Code

-----------

1. #include <stdio.h>

2.

3. void main(void)

4. {

5. goto bottom;

6.

7. printf("Not used\n"); // Code that is not used

8.

9. bottom:printf("Hello World!");

10. }

Additional reference words: 6.00 6.00a 6.00ax 7.00