Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion gcc -Wconversion and function with char argument
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Horst Kraemer  
View profile  
 More options Feb 8 1999, 3:00 am
Newsgroups: gnu.gcc.bug
From: horst.krae...@snafu.de (Horst Kraemer)
Date: 1999/02/08
Subject: Re: gcc -Wconversion and function with char argument

[ 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.