[Bug c/61939] warn when __attribute__((aligned(x))) is ignored
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61939 --- Comment #4 from Eric Gallager --- (In reply to Daniel Santos from comment #2) > (In reply to Vedran Miletic from comment #1) > > #include > > #include > > float f(std::vector& A, std::vector& B) > > { > > __builtin_assume_aligned(A.data(), 64); > > __builtin_assume_aligned(B.data(), 64); > > return std::inner_product(A.begin(), A.end(), B.begin(), 0.f); > > } > > You are doing it wrong. __builtin_assume_aligned() returns void* and you > must use it's return value for it to be effective. Sounds like __builtin_assume_aligned() should be marked up with __attribute__((warn_unused_result))
[Bug c/61939] warn when __attribute__((aligned(x))) is ignored
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61939 Eric Gallager changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-07-30 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #3 from Eric Gallager --- I had to modify the original testcase a bit to get it to compile: $ cat 61939.c struct some_struct { int foo; }; void copy_something(void *p, const void *s) { struct some_struct __attribute__((aligned(8))) *_d = p; struct some_struct __attribute__((aligned(8))) *_s = s; *_d = *_s; } $ /usr/local/bin/gcc -c -Wall -Wextra -pedantic -Wcast-align -Wattributes 61939.c 61939.c: In function ‘copy_something’: 61939.c:4:58: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] struct some_struct __attribute__((aligned(8))) *_s = s; ^ $ But beyond that, yeah, confirmed. I think there's probably a duplicate around here somewhere but I've forgotten the number already...
[Bug c/61939] warn when __attribute__((aligned(x))) is ignored
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61939 --- Comment #2 from Daniel Santos --- (In reply to Vedran Miletic from comment #1) > #include > #include > float f(std::vector& A, std::vector& B) > { > __builtin_assume_aligned(A.data(), 64); > __builtin_assume_aligned(B.data(), 64); > return std::inner_product(A.begin(), A.end(), B.begin(), 0.f); > } You are doing it wrong. __builtin_assume_aligned() returns void* and you must use it's return value for it to be effective. So your code should be something like this: float f(std::vector& A, std::vector& B) { float *a_data = __builtin_assume_aligned(A.data(), 64); float *b_data = __builtin_assume_aligned(B.data(), 64); return std::inner_product(a_data, b_data, B.begin(), 0.f); } Of course, this assumes that the buffer that your vector<> implementation supplies is 64 byte aligned.
[Bug c/61939] warn when __attribute__((aligned(x))) is ignored
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61939 Vedran Miletic changed: What|Removed |Added CC||rivanvx at gmail dot com --- Comment #1 from Vedran Miletic --- Confirmed still occurs in 6.2.1 on the following C++ code: #include #include float f(std::vector& A, std::vector& B) { __builtin_assume_aligned(A.data(), 64); __builtin_assume_aligned(B.data(), 64); return std::inner_product(A.begin(), A.end(), B.begin(), 0.f); } Compiled using -O3 -ffast-math -mavx2.