public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bugdal at aerifal dot cx" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/94631] New: Wrong codegen for arithmetic on bitfields Date: Fri, 17 Apr 2020 04:53:22 +0000 [thread overview] Message-ID: <bug-94631-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94631 Bug ID: 94631 Summary: Wrong codegen for arithmetic on bitfields Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bugdal at aerifal dot cx Target Milestone: --- Test case: struct foo { unsigned long long low:12, hi:52; }; unsigned long long bar(struct foo *p) { return p->hi*4096; } Should generate only a mask off of the low bits, but gcc generates code to mask off the low 12 bits and the high 12 bits (reducing the result to 52 bits). Presumably GCC is interpreting the expression p->hi as having a phantom type that's only 52 bits wide, rather than having type unsigned long long. clang/LLVM compiles it correctly. I don't believe there's any language in the standard supporting what GCC is doing here.
next reply other threads:[~2020-04-17 4:53 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-17 4:53 bugdal at aerifal dot cx [this message] 2020-04-17 5:09 ` [Bug c/94631] " pinskia at gcc dot gnu.org 2020-04-17 5:17 ` bugdal at aerifal dot cx 2020-04-17 5:34 ` pinskia at gcc dot gnu.org 2020-04-17 8:09 ` rguenth at gcc dot gnu.org 2020-04-17 15:55 ` bugdal at aerifal dot cx 2020-04-17 20:43 ` joseph at codesourcery dot com 2020-04-17 20:50 ` bugdal at aerifal dot cx 2020-04-17 20:54 ` bugdal at aerifal dot cx 2022-10-26 0:05 ` pinskia at gcc dot gnu.org
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=bug-94631-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).