-
Notifications
You must be signed in to change notification settings - Fork 103
Description
SIKE triggers many compiler warnings, especially on the most recent version of GCC. This is prohibitive to compiling with -Wall -Werror as is generally recommended. Some of these warnings suggest possibly invalid behaviour. The below logs are copied from this issue on downstream liboqs but I can reproduce them trivially by calling make on this repo.
The problem appears to lie in -Warray-parameter=2, which is included in -Wall. It appears by adding either to the makefile here.
At level 2 the warning also triggers for redeclarations involving any other inconsistency in array or pointer argument forms denoting array sizes. Pointers and arrays of unspecified bound are considered equivalent and do not
trigger a warning.void g (int*); void g (int[]); // no warning void g (int[8]); // warning (inconsistent array bound)
In file included from ../src/kem/sike/external/P503/P503.c:164:
../src/kem/sike/external/P503/../fpx.c:90:35: error: argument 1 of type ‘const digit_t[8]’ {aka ‘const long unsigned int[8]’} with mismatched bound [-Werror=array-parameter=]
90 | __inline void fpcopy(const felm_t a, felm_t c)
| ~~~~~~~~~~~~~^
In file included from ../src/kem/sike/external/P503/P503.c:10:
../src/kem/sike/external/P503/P503_internal.h:148:38: note: previously declared as ‘const digit_t *’ {aka ‘const long unsigned int *’}
148 | static void fpcopy503(const digit_t *a, digit_t *c);
| ~~~~~~~~~~~~~~~^
It also fails on -Warray-bounds.
In file included from ../src/kem/sike/external/P751/P751_compressed.c:435:
../src/kem/sike/external/P751/../compression/dlog.c: In function ‘Traverse_w_div_e_torus.constprop’:
../src/kem/sike/external/P751/../compression/dlog.c:166:13: error: array subscript 3 is above array bounds of ‘digit_t[3][2][12]’ {aka ‘long unsigned int[3][2][12]’} [-Werror=array-bounds]
166 | d = mod(ord2w_dlog(&H[W_2_1][0], logT, Texp), (1 << W_2_1));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/kem/sike/external/P751/../compression/dlog.c:141:13: note: while referencing ‘H’
141 | f2elm_t H[W_2_1] = {0}; // Size of H should be max of {W_2_1, W_2 - W_2_1}
| ^
And on -Wstringop-overflow. I don't even need to enable extra warnings for this one to show up here.
In function ‘CompleteMPoint’,
inlined from ‘BuildOrdinary2nBasis_dual’ at ../src/kem/sike/external/P751/../compression/torsion_basis.c:440:5,
inlined from ‘EphemeralKeyGeneration_B_extended’ at ../src/kem/sike/external/P751/../compression/sidh_compressed.c:630:5:
../src/kem/sike/external/P751/P751_compressed.c:400:21: error: ‘fp2mul751_mont’ accessing 192 bytes in a region of size 96 [-Werror=stringop-overflow=]
400 | #define fp2mul_mont fp2mul751_mont
../src/kem/sike/external/P751/../ec_isogeny.c:434:9: note: in expansion of macro ‘fp2mul_mont’
434 | fp2mul_mont(P->X, P->Z, xz); // xz = x*z;
| ^~~~~~~~~~~
../src/kem/sike/external/P751/../ec_isogeny.c: In function ‘EphemeralKeyGeneration_B_extended’:
../src/kem/sike/external/P751/P751_compressed.c:400:21: note: referencing argument 2 of type ‘const digit_t (*)[12]’ {aka ‘long unsigned int (*)[12]’}
400 | #define fp2mul_mont fp2mul751_mont
../src/kem/sike/external/P751/../ec_isogeny.c:434:9: note: in expansion of macro ‘fp2mul_mont’
434 | fp2mul_mont(P->X, P->Z, xz); // xz = x*z;
| ^~~~~~~~~~~
../src/kem/sike/external/P751/P751_compressed.c:400:21: note: in a call to function ‘fp2mul751_mont’
400 | #define fp2mul_mont fp2mul751_mont
| ^~~~~~~~~~~~~~
../src/kem/sike/external/P751/../fpx.c:320:13: note: in expansion of macro ‘fp2mul_mont’
320 | static void fp2mul_mont(const f2elm_t a, const f2elm_t b, f2elm_t c)
| ^~~~~~~~~~~