This is the mail archive of the gcc-bugs@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 is broken for 'short' parameters.


On Thu, 27 Jul 2000, Philipp Thomas wrote:
> * Veksler Michael (mveksler@techunix.technion.ac.il) [20000727 12:21]:
> 
> > It looks wrong: short (or char) are promoted to 'int' both in K&R code and
> > in ISO C, so why do we need the warning?
> 
> No they're not! It's one of the differences between K&R and ISO, that
> Arguments don't get default promotion in the presence of prototypes.
>
I was talking about the assembly level promotion and not the C level.
Assembly level promotion happens on some architectures that will store 32
bit (or maybe 64) on the stack for every parameter even if it is shorter
(That excludes struct and 'long long' which can be bigger). short/char
will be cast to word size at function call (and cast back inside the
function).

So what you basicly say is that char, short, int and long should (and
are) treated as having different width. They are considered different even
when the given architecture assigns 32 bits to all of them (If we pass
parameters by 32 bit registers all the above types will be promoted to 32
bits at the assembly level). Am I right?

The bug/misbehavior/feature is in the misleading flag name (should
probably kept for backward compatibility) and in warning's text.
The text should look something like:
1. When short/char are not promoted to int:
   warning: passing arg 1 of `foo' was not promoted due to prototype
2. When int is converted to short/char due to prototype:
   warning: passing arg 1 of `foo' with different width due to prototype

> In ISO C, only arguments to vararg functions get default promotion (which,
> BTW, is the reason why gcc will warn if you do ' va_arg(arg, char)').
> 

  Michael


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