public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c/7696: Spurious shift warning Date: Sun, 06 Apr 2003 12:26:00 -0000 [thread overview] Message-ID: <20030406122601.27467.qmail@sources.redhat.com> (raw) The following reply was made to PR c/7696; it has been noted by GNATS. From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de> To: gcc-gnats@gcc.gnu.org, schwab@suse.de, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org Cc: Subject: Re: c/7696: Spurious shift warning Date: Sun, 6 Apr 2003 14:17:56 +0200 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7696 PR 7696 started out as a spurious warning on ia64 but it turns out that this is probably a wrong code generation bug on any 64bit arch. The source code in question is this: $ cat 7696.c struct ia64_psr { unsigned long cpl : 2; } x = {1}; main () { unsigned long y = ((unsigned long) x.cpl) << 40; printf ("%lx %d\n", y, sizeof (y)); return 0; } $ gcc -m64 7696.c 7696.c: In function `main': 7696.c:7: warning: left shift count >= width of type This program will print $ a.out 100 8 According to gdb the cast is thrown away early (build_binary_op doesn't see it at all), probably because the bitfield is of type unsigned long. But later on default_conversion sees that the precision is only two and converts x.cpl to an integer (instead of a long). This oviouly hurts on arches where int has 32 bit but long has 64. Two different work arounds can be used to cure the problem: either declare the bitfield as int or cast x.cpl to long long instead of long. Obviously none of these is a fix. I'll see if I can come up with a patch. regards Christian -- THAT'S ALL FOLKS!
next reply other threads:[~2003-04-06 12:26 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-04-06 12:26 Christian Ehrhardt [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-04-06 15:26 Falk Hueffner 2003-01-08 2:15 bangerth 2002-08-23 5:06 Andreas Schwab
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030406122601.27467.qmail@sources.redhat.com \ --to=ehrhardt@mathematik.uni-ulm.de \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).