This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/6515: incorrect bitfield promotion
- From: ms at siroyan dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 30 Apr 2002 09:09:54 -0000
- Subject: c/6515: incorrect bitfield promotion
- Reply-to: ms at siroyan dot com
>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