https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81022
Bug ID: 81022 Summary: invalid address with pointer type casting Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vvsed at hotmail dot com Target Milestone: --- Created attachment 41505 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41505&action=edit same source code /* D:\Tools\MinGW64\bin\g++.exe -m64 -O2 -Wall -save-temps gcerr_1.cpp -ovx_class_gc Compiler: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/ MinGW 7.1 and below OS: Windows 7 or Linux 64-bit on Intel x64 invalid address with pointer type casting */ #include <stdio.h> #include <emmintrin.h> typedef long long int type; type dst[2]; void srt(type *src) { type *p, t; p = src + 1; t = p[0]; p--; if (src[1] < src[0]) { p[1] = p[0]; p--; } #if __SSE2__ _mm_store_sd((double *)(p + 1), _mm_load_sd((double *)&t)); //invalid address // _mm_storel_epi64((__m128i *)(p + 1), _mm_loadl_epi64((__m128i *)&t)); //ok #else p[1] = t; //ok #endif dst[0] = src[0]; dst[1] = src[1]; } int main() { type src[2] = {1, 0}; srt(src); fprintf(stdout, "%lld %lld", dst[0], dst[1]); //prints "1 1" instead of "0 1" return 0; }