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.


* Veksler Michael (mveksler@techunix.technion.ac.il) [20000727 08:30]:

>  void foo(short);
>  int main()
>  {
>    short s=1;
>    foo(s);
>    return 0;
>  }
> 
> This gives the following (obviously wrong) warning:
>    warning: passing arg 1 of `foo' with different width due to prototype

No, it's correct. Let me quote from the documentation

`-Wconversion'
     Warn if a prototype causes a type conversion that is different from
     what would happen to the same argument in the absence of a prototype. 

If there had been no prototype or a K&R one, s would have been promoted to
int in the call to foo. -Wconversion is only good for porting K&R code to
ISO C, because it warns you of possible pitfalls.

Philipp

-- 
Philipp Thomas <pthomas@suse.de>
Development, SuSE GmbH, Schanzaecker Str. 10, D-90443 Nuremberg, Germany

#define NINODE  50              /* number of in core inodes */
#define NPROC   30              /* max number of processes */
 	-- Version 7 UNIX for PDP 11, /usr/include/sys/param.h

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