Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I disable the C compiler signed/unsigned mismatch warning?

The Microsoft C compiler warns when you try to compare two variables, and one is signed, and the other is unsigned. For example:

int a;    
unsigned b;

if ( a < b ) { // warning C4018: '&lt;' : signed/unsigned mismatch

}

Has this warning, in the history of the world, ever caught a real bug? Why's it there, anyway?

like image 606
Steve Hanov Avatar asked Feb 05 '09 13:02

Steve Hanov


People also ask

What is signed unsigned mismatch?

A signed unsigned mismatch is an error that can be caused when one or more variables are incorrectly cast. In C++, integer types are represented as sign-and-magnitude integers.

How do I turn off compiler warning?

Turn off the warning for a project in Visual StudioSelect the Configuration Properties > C/C++ > Advanced property page. Edit the Disable Specific Warnings property to add 4996 . Choose OK to apply your changes.

Should warnings be ignored C++?

Warnings must not be ignored. You'd better fix every possible error before starting software testing. You may waste much time and effort to find an error in the debugger, although the compiler gives you an explicit warning about it.


1 Answers

Never ignore compiler warnings.

like image 123
Marko Avatar answered Oct 04 '22 11:10

Marko