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]

Re: -Wconversion not right (<32 bit problem)


What -Wconversion is doing is telling you that the code has different
semantics with the prototype than it does without the prototype.

This does not mean the code is wrong.

What this means is if you started with K&R C code, and added a prototype,
and expected to get the same program, then you added the wrong prototype.

However, if you had ANSI C code all along, then the warning may not be
telling you anything useful.

Part of the problem here is that -Wconversion does two different things:
1) It emits warnings for ANSI C code using questionable constructs.
2) It emits warnings that are useful for people converting K&R C code to
   ANSI C.

It was a historical error that the two different things got mixed together
in a single option.

	 Does this imply that even though I am passing a
	16 bit quantity, a 32-bit quantity is pushed on the stack? If so this is
	BAD news.

Yes, gcc does pass a 32-bit quantity, because that gives more efficient code,
and is compatible with how other x86 compilers work.

Pushing a 2 byte quantity to the stack is not very useful, because that would
cause the stack to become unaligned.

Most compilers work this way.  Parameters are always passed as values which
are a multiple of the word size.

Jim


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