From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10966 invoked by alias); 2 May 2003 20:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10952 invoked by uid 71); 2 May 2003 20:56:00 -0000 Date: Fri, 02 May 2003 20:56:00 -0000 Message-ID: <20030502205600.10950.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Zack Weinberg Subject: Re: c/10604: -Wall includes sign conversion warning [3.3 regression] Reply-To: Zack Weinberg X-SW-Source: 2003-05/txt/msg00154.txt.bz2 List-Id: The following reply was made to PR c/10604; it has been noted by GNATS. From: Zack Weinberg To: ak@suse.de Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: c/10604: -Wall includes sign conversion warning [3.3 regression] Date: Fri, 02 May 2003 13:47:13 -0700 It looks like this was experimentally changed as part of the C option-parsing rewrite; since it clearly causes problems, it should be put back the way it was. I am testing the appended patch; Mark has approved it for 3.3 if it works. (The patch for 3.4 will be slightly more invasive, because I'm going to get rid of a historical wart at the same time; that will come later.) zw PR c/10604 * c-opts.c (c_common_decode_option ): Set warn_sign_compare for C++ only. * doc/invoke.texi: Clarify documentation of -Wsign-compare. * gcc.dg/compare7.c, g++.dg/warn/compare1.C: New testcases. =================================================================== Index: c-opts.c --- c-opts.c 21 Feb 2003 06:12:58 -0000 1.24.6.1 +++ c-opts.c 2 May 2003 20:38:22 -0000 @@ -699,7 +699,8 @@ c_common_decode_option (argc, argv) warn_parentheses = on; warn_return_type = on; warn_sequence_point = on; /* Was C only. */ - warn_sign_compare = on; /* Was C++ only. */ + if (c_language == clk_cplusplus) + warn_sign_compare = on; warn_switch = on; warn_strict_aliasing = on; =================================================================== Index: doc/invoke.texi --- doc/invoke.texi 23 Apr 2003 21:45:32 -0000 1.209.2.26 +++ doc/invoke.texi 2 May 2003 20:44:55 -0000 @@ -2634,8 +2634,8 @@ casts like @code{(unsigned) -1}. @cindex signed and unsigned values, comparison warning Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. -This warning is also enabled by @option{-W}; to get the other warnings -of @option{-W} without this warning, use @samp{-W -Wno-sign-compare}. +This warning is enabled by @option{-W}, and by @option{-Wall} +in C++ only. @item -Waggregate-return @opindex Waggregate-return =================================================================== Index: testsuite/g++.dg/warn/compare1.C --- testsuite/g++.dg/warn/compare1.C 1 Jan 1970 00:00:00 -0000 +++ testsuite/g++.dg/warn/compare1.C 2 May 2003 20:38:23 -0000 @@ -0,0 +1,10 @@ +/* -Wall is supposed to trigger -Wsign-compare for C++. PR 10604. + See also gcc.dg/compare7.c. */ + +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int f(unsigned a, int b) +{ + return a < b; /* { dg-warning "signed and unsigned" } */ +} =================================================================== Index: testsuite/gcc.dg/compare7.c --- testsuite/gcc.dg/compare7.c 1 Jan 1970 00:00:00 -0000 +++ testsuite/gcc.dg/compare7.c 2 May 2003 20:38:24 -0000 @@ -0,0 +1,10 @@ +/* -Wall is not supposed to trigger -Wsign-compare for C. PR 10604. + See also g++.dg/warn/compare1.C. */ + +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int f(unsigned a, int b) +{ + return a < b; /* { dg-bogus "signed and unsigned" } */ +}