From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29658 invoked by alias); 19 Aug 2008 08:42:36 -0000 Received: (qmail 29650 invoked by uid 22791); 19 Aug 2008 08:42:36 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Aug 2008 08:41:47 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m7J8fjZE030670; Tue, 19 Aug 2008 04:41:45 -0400 Received: from zebedee.pink (vpn-12-59.rdu.redhat.com [10.11.12.59]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m7J8fgIx002644; Tue, 19 Aug 2008 04:41:43 -0400 Message-ID: <48AA8746.8010603@redhat.com> Date: Tue, 19 Aug 2008 13:24:00 -0000 From: Andrew Haley User-Agent: Thunderbird 2.0.0.16 (X11/20080707) MIME-Version: 1.0 To: "Sivaprasad.pv" CC: gcc Subject: Re: regarding type promotion References: <48AA5377.9080001@redpinesignals.com> In-Reply-To: <48AA5377.9080001@redpinesignals.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00166.txt.bz2 Sivaprasad.pv wrote: > If we consider following sample C language code : > > long long int k=0x123; > int p=1; > k = k + p << 33; > > Here the value in variable 'p' is shifted by 33 and then the result > (only 32 bit result)was promoted to 64 bit. > Is it an expected behavior? Yes. > Is there any way to specify in gcc to perform implicit type promotion > first and then perform operation on it (without explicit type casting). I'm not sure exactly what you mean by "without explicit type casting", but the correct way to write this is k = k + (long long)p << 33; The promotion rules are part of the language standard. Andrew.