MK-TFHE icon indicating copy to clipboard operation
MK-TFHE copied to clipboard

Disable 'restricted' warning in spqlios-fft-impl.cpp

Open KarlCHansen opened this issue 4 years ago • 0 comments

Compiling branch Master under Ubuntu 20.04, gcc version 9.3.0, gives errors for tests which use the same pointer as 1st and 2nd parameters, e.g. sub4(tmp0, tmp0, tmp3);.

$ gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.


[  1%] Building CXX object libtfhe/fft_processors/spqlios/CMakeFiles/tfhe-fft-spqlios-fma.dir/spqlios-fft-impl.cpp.o
/mnt/hd1/geneial/project/MK-TFHE/src/libtfhe/fft_processors/spqlios/spqlios-fft-impl.cpp: In function ‘void fft_model(const void*)’:
/mnt/hd1/geneial/project/MK-TFHE/src/libtfhe/fft_processors/spqlios/spqlios-fft-impl.cpp:347:32: error: ‘-Werror=restrict’ is not an option that controls warnings [-Werror=pragmas]
  347 | #pragma GCC diagnostic ignored "-Werror=restrict"
      |                                ^~~~~~~~~~~~~~~~~~
/mnt/hd1/geneial/project/MK-TFHE/src/libtfhe/fft_processors/spqlios/spqlios-fft-impl.cpp:352:22: error: passing argument 1 to restrict-qualified parameter aliases with argument 2 [-Werror=restrict]
  352 |                 sub4(tmp0, tmp0, tmp3); // re2
      |                      ^~~~  ~~~~
/mnt/hd1/geneial/project/MK-TFHE/src/libtfhe/fft_processors/spqlios/spqlios-fft-impl.cpp:353:22: error: passing argument 1 to restrict-qualified parameter aliases with argument 2 [-Werror=restrict]
  353 |                 add4(tmp1, tmp1, tmp2); // im2
      |                      ^~~~  ~~~~
/mnt/hd1/geneial/project/MK-TFHE/src/libtfhe/fft_processors/spqlios/spqlios-fft-impl.cpp:356:22: error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
  356 |                 sub4(tmp0, re0, tmp0); // re - re
      |                      ^~~~       ~~~~
/mnt/hd1/geneial/project/MK-TFHE/src/libtfhe/fft_processors/spqlios/spqlios-fft-impl.cpp:357:22: error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
  357 |                 sub4(tmp1, im0, tmp1); // im - im
      |                      ^~~~       ~~~~
cc1plus: all warnings being treated as errors

Fix by adding GCC pragmas (other platforms may require alternate fixes) around the offending code (lines 346...359):

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wrestrict"
                dotp4(tmp0, re1, tcs); // re*cos
                dotp4(tmp1, re1, tsn); // re*sin
                dotp4(tmp2, im1, tcs); // im*cos
                dotp4(tmp3, im1, tsn); // im*sin
                sub4(tmp0, tmp0, tmp3); // re2
                add4(tmp1, tmp1, tmp2); // im2
                add4(tmp2, re0, tmp0); // re + re
                add4(tmp3, im0, tmp1); // im + im
                sub4(tmp0, re0, tmp0); // re - re
                sub4(tmp1, im0, tmp1); // im - im
                copy4(re0, tmp2);
                copy4(im0, tmp3);
                copy4(re1, tmp0);
                copy4(im1, tmp1);
#pragma GCC diagnostic pop

KarlCHansen avatar Sep 28 '20 01:09 KarlCHansen