[Bug target/71475] [5/6/7 Regression] Optimization of copying into long double looses bytes
ch3root at openwall dot com
gcc-bugzilla@gcc.gnu.org
Fri Jun 10 14:12:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71475
--- Comment #6 from Alexander Cherepanov <ch3root at openwall dot com> ---
Ok, what about this:
----------------------------------------------------------------------
#include <string.h>
#include <stdio.h>
int main()
{
long double d;
char s[sizeof(long double)];
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 20160608 (experimental)
More information about the Gcc-bugs
mailing list