Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion gcc -Wconversion and function with char argument

From: horst.krae...@snafu.de (Horst Kraemer)
Subject: Re: gcc -Wconversion and function with char argument
Date: 1999/02/08
Message-ID: <36beec03.264898408@news.snafu.de>#1/1
X-Deja-AN: 442071741
Sender: bug-gcc-requ...@mail.gnu.org
Approved: bug-gcc-requ...@mail.gnu.org
References: <36BEE1F2.30B4E107@inist.fr>
x-uunet-gateway: relay4.UU.NET from bug-gcc to gnu.gcc.bug; Mon, 8 Feb 1999 14:21:16 EST
Organization: [Posted via] Interactive Networx
Newsgroups: gnu.gcc.bug


[ posted and mailed]

On Mon, 08 Feb 1999 14:09:07 +0100, ludovic.wa...@inist.fr (Ludovic
WALLE) wrote:


> When I try to compile the following source file chararg.c:
> 
>      void f (char c) {}
> 
>      int main ()
>      {
>          f ('A');
>      }
> 
> with the -Wconversion option:
> 
>      gcc -Wconversion chararg.c
> 
> I get the message:
> 
>      chararg.c: In function `main':
>      chararg.c:5: warning: passing arg 1 of `f' with different
>      width due to prototype
> 
> It seems to happend with any function having a char argument.


Correct. Perhaps you misunderstood the meaning of '-Wconversion'.

-Wconversion warns whenever the declaration

	void f (char c);

would lead to a different conversion sequence than the prototype-less
declaration

	void f();


If you call f('A') then the argument 'A' has type int.

If f is declared as 'void f(char)' then 'A' will be converted to char
before it is passed to f. If f is declared as 'void f()' then 'A' will
be passed to f "as is", i.e. as an int.



Regards
Horst