This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: No Compilation Warning...


Manje Gowda S G wrote:
1) There is some fundamental reason behind this, I am not aware..., any light on this is greatly appreciated.

The real reason for this is probably "an accident of history".


However, K&R C and ISO C have different rules for promoting types when you mix types with different sizes and different signedness. Thus it makes some sense to emit warnings by default in this case, as this will help catch problems in code that may have been written for a different version of the C language. It makes no difference for this specific example, but in general it may make a difference.

There is also the problem that it is easy to type a number that is too large for a small type, like short, but that can't happen for int, as then you would have a parse error. So it makes more sense to have range checks for types smaller than int than it does to have them for int.

2) STILL...,
	unsigned int s;
	if (0 <= s) {....}

If you use -Wextra, you will get a warning. See the documentation. This is a different warning message than the one you get for shorts.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]