public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/94631] New: Wrong codegen for arithmetic on bitfields
@ 2020-04-17  4:53 bugdal at aerifal dot cx
  2020-04-17  5:09 ` [Bug c/94631] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: bugdal at aerifal dot cx @ 2020-04-17  4:53 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2022-10-26  0:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17  4:53 [Bug c/94631] New: Wrong codegen for arithmetic on bitfields bugdal at aerifal dot cx
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

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).