public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/6346: sign extension missing after cast down and up on long long bitfield
@ 2002-04-18  1:56 Servatius.Brandt
  0 siblings, 0 replies; 2+ messages in thread
From: Servatius.Brandt @ 2002-04-18  1:56 UTC (permalink / raw)
  To: gcc-gnats; +Cc: Joachim.Canisius, Erwin.Unruh, Heinrich.Brand


>Number:         6346
>Category:       c
>Synopsis:       sign extension missing after cast down and up on long long bitfield
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 18 01:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Servatius.Brandt@fujitsu-siemens.com
>Release:        gcc-3.0.4
>Organization:
>Environment:
sparc-sun-solaris2.8
>Description:
After converting the result of the |= operation on an
unsigned long long bitfield down to a signed char or short,
the conversion up to long long or unsigned long long forgets
the sign extension.

The problem is the same with and without optimization.
>How-To-Repeat:
gcc bug15.c && ./a.out

Output is 256, 256, 65536, 65536, -1, -1, -1, -1.
Correct output would be "-1" eigth times.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug15.c"; name="bug15.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug15.c"

c3RydWN0IEMgewogICAgdW5zaWduZWQgbG9uZyBsb25nIGYxIDogODsKICAgIHVuc2lnbmVkIGxv
bmcgbG9uZyBjMSA6IDE2Owp9OwoKbWFpbigpCnsKICAgIHN0cnVjdCBDIHY7CiAgICB2LmMxID0g
MDsKCiAgICAvKiBBZnRlciBjb252ZXJ0aW5nIHRoZSByZXN1bHQgb2YgdGhlIHw9IG9wZXJhdGlv
biBvbiBhbiB1bnNpZ25lZCBsb25nIGxvbmcKICAgICAqIGJpdGZpZWxkIGRvd24gdG8gYSBzaWdu
ZWQgY2hhciBvciBzaG9ydCwgdGhlIGNvbnZlcnNpb24gdXAgdG8gbG9uZyBsb25nCiAgICAgKiBv
ciB1bnNpZ25lZCBsb25nIGxvbmcgZm9yZ2V0cyB0aGUgc2lnbiBleHRlbnNpb24uICovCiAgICBw
cmludGYoIiVsbGRcbiIsICAgICAgICAgIChsb25nIGxvbmcpKHNpZ25lZCBjaGFyKSh2LmMxIHw9
IC0xTEwpKTsKICAgIHByaW50ZigiJWxsZFxuIiwgKHVuc2lnbmVkIGxvbmcgbG9uZykoc2lnbmVk
IGNoYXIpKHYuYzEgfD0gLTFMTCkpOwogICAgcHJpbnRmKCIlbGxkXG4iLCAgICAgICAgICAobG9u
ZyBsb25nKShzaG9ydCkgICAgICAodi5jMSB8PSAtMUxMKSk7CiAgICBwcmludGYoIiVsbGRcbiIs
ICh1bnNpZ25lZCBsb25nIGxvbmcpKHNob3J0KSAgICAgICh2LmMxIHw9IC0xTEwpKTsKCiAgICAv
KiBUaGlzIHdvcmtzIGNvcnJlY3RseS4gKi8KICAgIHByaW50ZigiJWxsZFxuIiwgICAgICAgICAg
KGxvbmcgbG9uZykoc2lnbmVkIGNoYXIpKC0xTEwpKTsKICAgIHByaW50ZigiJWxsZFxuIiwgKHVu
c2lnbmVkIGxvbmcgbG9uZykoc2lnbmVkIGNoYXIpKC0xTEwpKTsKICAgIHByaW50ZigiJWxsZFxu
IiwgICAgICAgICAgKGxvbmcgbG9uZykoc2hvcnQpICAgICAgKC0xTEwpKTsKICAgIHByaW50Zigi
JWxsZFxuIiwgKHVuc2lnbmVkIGxvbmcgbG9uZykoc2hvcnQpICAgICAgKC0xTEwpKTsKCiAgICAv
KiBFeHBlY3RlZCByZXN1bHRzOiAtMSwgLTEsIC0xLCAtMSwgLTEsIC0xLCAtMSwgLTEuICovCiAg
ICAvKiBPdXRwdXQgaXM6IDI1NSwgMjU1LCA2NTUzNSwgNjU1MzUsIC0xLCAtMSwgLTEsIC0xLiAq
Lwp9Cg==


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c/6346: sign extension missing after cast down and up on long long bitfield
@ 2002-05-22  5:09 neil
  0 siblings, 0 replies; 2+ messages in thread
From: neil @ 2002-05-22  5:09 UTC (permalink / raw)
  To: Erwin.Unruh, Heinrich.Brand, Joachim.Canisius, Servatius.Brandt,
	gcc-bugs, gcc-prs, neil, nobody

Synopsis: sign extension missing after cast down and up on long long bitfield

Responsible-Changed-From-To: unassigned->neil
Responsible-Changed-By: neil
Responsible-Changed-When: Wed May 22 05:08:57 2002
Responsible-Changed-Why:
    Bitfield issues are assigned to me, though I doubt I'll
    have time to fix them until 3.3.
State-Changed-From-To: open->analyzed
State-Changed-By: neil
State-Changed-When: Wed May 22 05:08:57 2002
State-Changed-Why:
    Bitfields have several issues, fundamentally down to the
    single fact that their type is not represented properly in the
    compiler.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6346


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-05-22 12:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-18  1:56 c/6346: sign extension missing after cast down and up on long long bitfield Servatius.Brandt
2002-05-22  5:09 neil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).