From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12360 invoked by alias); 27 Dec 2002 03:16:42 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 12350 invoked from network); 27 Dec 2002 03:16:41 -0000 Received: from unknown (HELO windlord.stanford.edu) (171.64.13.23) by 209.249.29.67 with SMTP; 27 Dec 2002 03:16:41 -0000 Received: (qmail 11349 invoked by uid 50); 27 Dec 2002 03:16:29 -0000 To: Gnu Compiler Collection Hackers Subject: Re: Bizarre warning about width of argument References: In-Reply-To: (Trevor Jenkins's message of "Fri, 27 Dec 2002 02:42:33 +0000 (GMT)") From: Russ Allbery Organization: The Eyrie Date: Fri, 27 Dec 2002 03:37:00 -0000 Message-ID: User-Agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Honest Recruiter, sparc-sun-solaris2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-12/txt/msg01438.txt.bz2 Trevor Jenkins writes: > When the following example is compiled we get a warning: > foo.c: In function `foo': > foo.c:8: warning: passing arg 1 of `bar' with different width due to prototype > This test case is extracted from a large system where these "errors" are > being reported all over the place. The gcc comand being used is > gcc -c -ansi -fno-nonansi-builtins -Wshadow -Wconversion foo.c > and here's the simplest test case we can find as foo.c: > #include > void foo(unsigned short); > void bar(unsigned short); > void foo(unsigned short zindex) > { > bar(zindex); > } > void bar(unsigned short a) > { > } The warning is correct for what -Wconversion is for. You probably don't want to use this flag with regular programs. `-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. This includes conversions of fixed point to floating and vice versa, and conversions changing the width or signedness of a fixed point argument except when the same as the default promotion. In other words, -Wconversion produces a warning if the presence of a prototype causes an argument to be converted to a different type than if there hadn't been a prototype. It's intended for helping in converting K&R C to ANSI C. In your test case above, without a prototype the unsigned short variable would be promoted to an int. -Wconversion produces warnings about perfectly valid and stylistically correct ANSI C. -- Russ Allbery (rra@stanford.edu)