From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15749 invoked by alias); 16 Feb 2008 17:00:51 -0000 Received: (qmail 15739 invoked by uid 22791); 16 Feb 2008 17:00:51 -0000 X-Spam-Check-By: sourceware.org Received: from wx-out-0506.google.com (HELO wx-out-0506.google.com) (66.249.82.233) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 16 Feb 2008 17:00:31 +0000 Received: by wx-out-0506.google.com with SMTP id s18so1136893wxc.14 for ; Sat, 16 Feb 2008 09:00:29 -0800 (PST) Received: by 10.142.141.21 with SMTP id o21mr3210856wfd.84.1203181228631; Sat, 16 Feb 2008 09:00:28 -0800 (PST) Received: by 10.142.86.17 with HTTP; Sat, 16 Feb 2008 09:00:28 -0800 (PST) Message-ID: <84fc9c000802160900h5660abd5n205da0e65ec3a50b@mail.gmail.com> Date: Sat, 16 Feb 2008 17:05:00 -0000 From: "Richard Guenther" To: "=?ISO-8859-1?Q?Manuel_L=F3pez-Ib=E1=F1ez?=" Subject: Re: [RFC] PR34389 -Wconversion produces wrong warning Cc: "GCC Patches" In-Reply-To: <6c33472e0802160852x17360ea9sb8c0945b6039f872@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <6c33472e0802160852x17360ea9sb8c0945b6039f872@mail.gmail.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-02/txt/msg00613.txt.bz2 On Feb 16, 2008 5:52 PM, Manuel L=F3pez-Ib=E1=F1ez = wrote: > The following patch fixes PR 34389 in a ugly way, in my own opinion, > but I am not able to come up with any other way to fix this. > > A more detailed analysis is in the PR. In summary the problem here is > that fold_unary converts (T)(x & c) into (T)x & (T)c which in this > case is (int) (x & 0x7fff) into ((int)x & 0x7fff). By using > get_unwidened, we could handle the first form. However, get_unwidened > won't handle the latter. Thus, when Wconversion sees that this > expression is assigned to a short, it concludes that there may be a > loss of precision. > > Bootstrapped and regression tested in x86_64-unknown-linux-gnu. This > patch only affects Wconversion, which is new in 4.3. The correct fix is to not fold expressions in the C frontend before doing these kinds of warnings. Richard.