From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9569 invoked by alias); 1 Dec 2005 12:46:18 -0000 Received: (qmail 9555 invoked by uid 48); 1 Dec 2005 12:46:16 -0000 Date: Thu, 01 Dec 2005 12:46:00 -0000 Message-ID: <20051201124616.9554.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/25186] (short)(((int)short_var) <<1) should be folded so that the shift is done in the short type In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2005-12/txt/msg00050.txt.bz2 List-Id: ------- Comment #5 from rguenth at gcc dot gnu dot org 2005-12-01 12:46 ------- I.e. 6.3.1.3/3 says that conversion from type T to signed type is implementation defined if the value doesn't fit. And we define it to reducing it modulo 2^N. So, for !flag_wrapv (short)((int)0x8000 << 1) == 0 but 0x8000 << 1 is undefined. So this transformation is only ok for flag_wrapv. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25186