https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71460
--- Comment #12 from Alexander Cherepanov <ch3root at openwall dot com> ---
On 2016-06-09 11:22, rguenth at gcc dot gnu.org wrote:
> Would be nice to have a testcase for the SRA case as well.
Source code:
----------------------------------------------------------------------
#define _GNU_SOURCE
#include <fenv.h>
struct s { double d; char c; };
__attribute__((noinline,noclone))
void copy(struct s *q, struct s *p)
{
struct s tmp = *p;
*q = tmp;
}
int main()
{
feenableexcept(FE_INVALID);
struct s x = {0}, y;
((unsigned char *)&x.d)[7] = 0x7f;
((unsigned char *)&x.d)[6] = 0xf0; // sNaN
((unsigned char *)&x.d)[0] = 0x01;
copy(&y, &x);
}
----------------------------------------------------------------------
Results:
----------------------------------------------------------------------
$ gcc -std=c11 -pedantic -Wall -Wextra -fsignaling-nans -lm -m32 -O3
test.c && ./a.out
Floating point exception
----------------------------------------------------------------------
gcc version: gcc (GCC) 7.0.0 20160608 (experimental)