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
* [Bug target/107403] uint64_t bitfield operation is mishandled 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 ` pinskia at gcc dot gnu.org 2022-10-26 0:00 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-10-26 0:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107403 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- No this is correct. i.y << 8ULL Is all done in 56bit type as the type is greater than the size of int. Note c allows this behavior while c++ does not. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/107403] uint64_t bitfield operation is mishandled 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 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-10-26 0:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107403 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note gcc and clang have different implementation defined behavior here too. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/107403] uint64_t bitfield operation is mishandled 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 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-10-26 0:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107403 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=92684 Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Dup of bug 94631. *** This bug has been marked as a duplicate of bug 94631 *** ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/107403] uint64_t bitfield operation is mishandled 2022-10-25 23:55 [Bug target/107403] New: uint64_t bitfield operation is mishandled hjl.tools at gmail dot com ` (2 preceding siblings ...) 2022-10-26 0:05 ` pinskia at gcc dot gnu.org @ 2022-10-26 0:06 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-10-26 0:06 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107403 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- See https://gcc.gnu.org/legacy-ml/gcc/2017-10/msg00192.html ^ 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).