public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/98502] New: Optimised memcpy breaks __scalar_storage_order__
@ 2021-01-03 7:49 noring at nocrew dot org
2021-01-03 8:28 ` [Bug middle-end/98502] " pinskia at gcc dot gnu.org
2021-01-03 9:03 ` noring at nocrew dot org
0 siblings, 2 replies; 3+ messages in thread
From: noring at nocrew dot org @ 2021-01-03 7:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98502
Bug ID: 98502
Summary: Optimised memcpy breaks __scalar_storage_order__
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: noring at nocrew dot org
Target Milestone: ---
Compiling with -O1 or greater breaks __scalar_storage_order__ with memcpy. The
expected output of the test program below (sso.c) is "1234" but "3412" is
produced with compiler optimisations:
% gcc -Wall -o sso sso.c && ./sso
1234
% gcc -Wall -O1 -o sso sso.c && ./sso
3412
sso.c:
#include <stdint.h>
#include <stdio.h>
#include <string.h>
int main()
{
const uint8_t b[] = { 0x12, 0x34 };
struct __attribute__(( __scalar_storage_order__("big-endian") )) {
uint16_t word;
} s;
memcpy(&s, b, sizeof(s));
printf("%04x\n", s.word);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/98502] Optimised memcpy breaks __scalar_storage_order__
2021-01-03 7:49 [Bug c/98502] New: Optimised memcpy breaks __scalar_storage_order__ noring at nocrew dot org
@ 2021-01-03 8:28 ` pinskia at gcc dot gnu.org
2021-01-03 9:03 ` noring at nocrew dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-01-03 8:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98502
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Component|c |middle-end
Status|UNCONFIRMED |RESOLVED
Target Milestone|--- |11.0
Resolution|--- |FIXED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I reported this in April 2020 (but not to a bug report because I did not know
if it was a bug or not):
https://gcc.gnu.org/pipermail/gcc/2020-April/000407.html
Fixed in GCC 11 by the patch in the referenced mailing list threads.
https://gcc.gnu.org/pipermail/gcc-patches/2020-June/546934.html
which continued the discussion to:
https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549596.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/98502] Optimised memcpy breaks __scalar_storage_order__
2021-01-03 7:49 [Bug c/98502] New: Optimised memcpy breaks __scalar_storage_order__ noring at nocrew dot org
2021-01-03 8:28 ` [Bug middle-end/98502] " pinskia at gcc dot gnu.org
@ 2021-01-03 9:03 ` noring at nocrew dot org
1 sibling, 0 replies; 3+ messages in thread
From: noring at nocrew dot org @ 2021-01-03 9:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98502
--- Comment #2 from Fredrik Noring <noring at nocrew dot org> ---
Thanks, Andrew. I felt certain it's a GCC bug. :) Will the patch be backported
to GCC 9.x and 10.x? It'll take a while before 11 is commonly available, I
think.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-03 9:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-03 7:49 [Bug c/98502] New: Optimised memcpy breaks __scalar_storage_order__ noring at nocrew dot org
2021-01-03 8:28 ` [Bug middle-end/98502] " pinskia at gcc dot gnu.org
2021-01-03 9:03 ` noring at nocrew dot 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).