From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27109 invoked by alias); 30 Apr 2002 09:16:06 -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 27030 invoked by uid 71); 30 Apr 2002 09:16:02 -0000 Resent-Date: 30 Apr 2002 09:16:02 -0000 Resent-Message-ID: <20020430091602.27029.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, ms@siroyan.com Received:(qmail 24041 invoked by uid 61); 30 Apr 2002 09:09:54 -0000 Message-Id:<20020430090954.24040.qmail@sources.redhat.com> Date: Tue, 30 Apr 2002 02:16:00 -0000 From: ms@siroyan.com Reply-To: ms@siroyan.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/6515: incorrect bitfield promotion X-SW-Source: 2002-04/txt/msg01623.txt.bz2 List-Id: >Number: 6515 >Category: c >Synopsis: incorrect bitfield promotion >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Apr 30 02:16:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: ms@siroyan.com >Release: 3.0.4 >Organization: >Environment: i686-pc-linux-gnu >Description: In the attached example test1() and test2() both perform a % operation. I expected an unsigned mod operation performed in both cases, in practice it only occurs in the second case, in the former case the (unsigned int)cast appears to have no effect. I expected: * x.b cast to (unsigned int) * x.a promoted to int by integral promotion * x.a converted to (unsigned int), by arithmetic conversion to bring x.a x.b to a common type. * unsigned mod applied to x.a and x.b >How-To-Repeat: gcc -O2 x.c ./a.out >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="x.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="x.c" c3RydWN0IHsKICBpbnQgYTo3OwogIHVuc2lnbmVkIGludCBiOjY7Cn0geDsKCnVuc2lnbmVkIGlu dCBhYSwgYmI7Cgppbml0ICgpCnsKICBhYSA9IHguYSA9IC0xMzsKICBiYiA9IHguYiA9IDYxOwp9 CgptYWluICgpCnsKICBpbml0ICgpOwogIHRlc3QxICgpOwogIHRlc3QyICgpOwp9Cgp0ZXN0MSAo KQp7CiAgcHJpbnRmICgiJWQgJSUgJWQgPSAlZFxuIiwgeC5hLCB4LmIsIHguYSAlICgodW5zaWdu ZWQgaW50KSB4LmIpKTsKfQoKdGVzdDIgKCkKewogIHByaW50ZiAoIiVkICUlICVkID0gJWRcbiIs IGFhLCBiYiwgYWEgJSBiYik7Cn0K