Condider this

/* bar.c */

void bar(char a)
{
   char b = a;
}

void frob(void)
{
   bar('a');
}

Due to the automatic promotion of char to int in function calls [same would
apply to short or C99 _Bool], then this causes a warning with -Wconversion,
thus:

gcc -Wconversion -c bar.c
bar.c: In function 'frob':
bar.c:10: warning: passing argument 1 of 'bar' with different width due to
prototype

This greatly limits the usefulness of -Wconversion.

As a user I either have to
a) put up with many thousands of useless warnings
b) not use -Wconversion, or use it with heavy filtering
c) never pass char/short/bool arguments in functions

A similar thing happens with float/double:
bar.c:10: warning: passing argument 1 of 'bar' as 'float' rather than 'double'
due to prototype

This only happens with gcc, not g++.


-- 
           Summary: Excessive warnings when using -Wconversion and
                    char/bool/short function arguments
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paulf at free dot fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38121

Reply via email to