error: ‘__Y’ is used uninitialized for immintrin.h when compiled with -O3 -Wall -Winit-self -Werror

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[Public]

Hello,

For the following testcase (and maybe similar others):

#include <immintrin.h>

void foo(double *c)
{
        __m256d ymm0 = _mm256_undefined_pd ();
        _mm256_store_pd (c, ymm0);
}

gcc (GCC) 12.1.1 20220711 gives following error when compiled with ‘gcc -O3 -Wall -Winit-self -Werror -mavx foo.c -c’:

In file included from /home/tejas/community/GCC-12/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/immintrin.h:43,
                 from foo.c:1:
In function ‘_mm256_store_pd’,
    inlined from ‘foo’ at foo.c:6:2:
/home/tejas/community/GCC-12/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/avxintrin.h:875:19: error: ‘__Y’ is used uninitialized [-Werror=uninitialized]
  875 |   *(__m256d *)__P = __A;
      |   ~~~~~~~~~~~~~~~~^~~~~
/home/tejas/community/GCC-12/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/avxintrin.h: In function ‘foo’:
/home/tejas/community/GCC-12/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/avxintrin.h:1210:11: note: ‘__Y’ was declared here
1210 |   __m256d __Y = __Y;
      |           ^~~
cc1: all warnings being treated as errors

This behavior is seen with GCC 12 and not with older GCC versions (tried with system GCC 9.4.0 and GCC 11.2). I see -Wuninitialized is introduced newly : <https://gcc.gnu.org/gcc-12/changes.html > (I don’t know though, if -Wuninitialized has anything to do with -Winit-self).
While I understand -Winit-self is supposed to give warnings for such, should it give a warning for immintrin.h itself? The testcase seems to be correct. Is it a bug in GCC 12 or is it supposed to behave like this?

Thanks and Regards,
Tejas
#include <immintrin.h>

void foo(double *c)
{
	__m256d ymm0 = _mm256_undefined_pd ();
	_mm256_store_pd (c, ymm0);
} 


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux