This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Weird warning


I've been digging a bit deeper after making sense of the warning. It seems that GCC simply misaligns __m256i values. In the attached example, the unaligned load/store works fine but the last line fails. The address in the output clearly shows that the memory is not aligned (not divisible by 32):

0x7ffff7f83010

Program received signal SIGSEGV, Segmentation fault.
0x00000000004008d0 in main () at avx-bug.cpp:17
17	  v[0].a[0] = v[0].a[0];

Best regards,
Marcel


On 09/11/16 16:54, Marcel Keller wrote:
Hi,

Running avx-bug.cpp compiled with GCC 6.2 and -mavx results in a
segfault here. The same happens with avx-bug2.cpp, but there I get the
following warning when compiling:

avx-bug2.cpp: In function ‘int main()’:
avx-bug2.cpp:6:22: warning: ignoring attributes on template argument
‘__m256i {aka __vector(4) long long int}’ [-Wignored-attributes]
   std::vector<__m256i> v(10000);
                      ^

I'm a bit confused what I should do about the warning and why it doesn't
appear in the functionally equivalent code.

Best regards,
Marcel


#include <vector>
#include <immintrin.h>

#include <iostream>
using namespace std;

union __attribute__((aligned(32))) U {
  __attribute__((aligned(32))) __m256i __attribute__((aligned(32))) a[1] __attribute__((aligned(32)));
} __attribute__((aligned(32)));

int main()
{
  U* v = new U[10000];
  cout << hex << v << endl;
  __m256i a = _mm256_loadu_si256(v->a);
  _mm256_storeu_si256(v->a, a);
  v[0].a[0] = v[0].a[0];
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]