public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/107403] New: uint64_t bitfield operation is mishandled
@ 2022-10-25 23:55 hjl.tools at gmail dot com
  2022-10-26  0:00 ` [Bug target/107403] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hjl.tools at gmail dot com @ 2022-10-25 23:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107403

            Bug ID: 107403
           Summary: uint64_t bitfield operation is mishandled
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---
            Target: x84

[hjl@gnu-cfl-1 tmp]$ cat foo.c
#include <stdint.h>
#include <stdio.h>

#define VAL (1ULL << 48)

struct foo
{
  uint64_t x : 8;
  uint64_t y : 56;
};

__attribute__ ((noinline))
uint64_t
func (struct foo i)
{
  return i.y << 8ULL;
}

int
main ()
{
  struct foo i;
  i.x = 0;
  i.y = VAL;
  uint64_t x = func (i);
  printf ("0x%llx\n", x);
  printf ("0x%llx\n", VAL);
  if (x != (VAL << 8ULL))
    __builtin_abort ();
}
[hjl@gnu-cfl-1 tmp]$ gcc foo.c
[hjl@gnu-cfl-1 tmp]$ ./a.out 
0x0
0x1000000000000
Aborted (core dumped)
[hjl@gnu-cfl-1 tmp]$

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 23:55 [Bug target/107403] New: uint64_t bitfield operation is mishandled hjl.tools at gmail dot com
2022-10-26  0:00 ` [Bug target/107403] " pinskia at gcc dot gnu.org
2022-10-26  0:00 ` pinskia at gcc dot gnu.org
2022-10-26  0:05 ` pinskia at gcc dot gnu.org
2022-10-26  0:06 ` 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).