This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/71522] New: Wrong optimization of memcpy through a var of type long double
- From: "ch3root at openwall dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 13 Jun 2016 13:55:08 +0000
- Subject: [Bug c/71522] New: Wrong optimization of memcpy through a var of type long double
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71522
Bug ID: 71522
Summary: Wrong optimization of memcpy through a var of type
long double
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ch3root at openwall dot com
Target Milestone: ---
Source code:
----------------------------------------------------------------------
#include <string.h>
#include <stdio.h>
int main()
{
long double d;
char s[sizeof d];
memcpy(&d, "AAAAAAAAAAAAAAA", sizeof d);
memcpy(&s, &d, sizeof s);
printf("%s\n", s);
}
----------------------------------------------------------------------
Results:
----------------------------------------------------------------------
$ gcc -std=c11 -pedantic -Wall -Wextra test.c && ./a.out
AAAAAAAAAAAAAAA
$ gcc -std=c11 -pedantic -Wall -Wextra -O3 test.c && ./a.out
AAAAAAAA
----------------------------------------------------------------------
gcc version: gcc (GCC) 7.0.0 20160613 (experimental)
The effect is very similar to bug 71452 so, presumably, this also considered a
bug.