xiaoyeli / superlu_mt

Other
20 stars 12 forks source link

sreadmt.c:29:1: error: conflicting types #18

Closed sagitter closed 6 months ago

sagitter commented 6 months ago

Hi all.

superlu_mt-4.0.1 is failing with GCC-14 with following errors:

gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  -lgomp -lflexiblas64 -fPIC -D__OPENMP -DPRNTlevel=0 -DDEBUGlevel=0 -D_LONGINT -DAdd_  -L/usr/lib64 -lflexiblas64 -c sreadmt.c 
sreadmt.c:29:1: error: conflicting types for ‘sreadmt’; have ‘void(int *, int *, int *, float **, int **, int **)’
   29 | sreadmt(int *m, int *n, int *nonz, float **nzval, int **rowind, int **colptr)
      | ^~~~~~~
In file included from sreadmt.c:22:
slu_mt_sdefs.h:417:13: note: previous declaration of ‘sreadmt’ with type ‘void(int_t *, int_t *, int_t *, float **, int_t **, int_t **)’ {aka ‘void(long long int *, long long int *, long long int *, float **, long long int **, long long int **)’}
  417 | extern void sreadmt (int_t *, int_t *, int_t *, float **, int_t **, int_t **);
      |             ^~~~~~~
sreadmt.c: In function ‘sreadmt’:
sreadmt.c:62:34: error: passing argument 4 of ‘sallocateA’ from incompatible pointer type [-Wincompatible-pointer-types]
   62 |     sallocateA(*n, *nonz, nzval, rowind, colptr); /* Allocate storage */
      |                                  ^~~~~~
      |                                  |
      |                                  int **
slu_mt_sdefs.h:333:49: note: expected ‘int_t **’ {aka ‘long long int **’} but argument is of type ‘int **’
  333 | extern void sallocateA (int_t, int_t, float **, int_t **, int_t **);
      |                                                 ^~~~~~~~
sreadmt.c:62:42: error: passing argument 5 of ‘sallocateA’ from incompatible pointer type [-Wincompatible-pointer-types]
   62 |     sallocateA(*n, *nonz, nzval, rowind, colptr); /* Allocate storage */
      |                                          ^~~~~~
      |                                          |
      |                                          int **
slu_mt_sdefs.h:333:59: note: expected ‘int_t **’ {aka ‘long long int **’} but argument is of type ‘int **’
  333 | extern void sallocateA (int_t, int_t, float **, int_t **, int_t **);
      |                                                           ^~~~~~~~
sreadmt.c:61:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   61 |     scanf("%d%d%d", m, n, nonz);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
sreadmt.c:68:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   68 |         scanf("%d", &nnz);
      |         ^~~~~~~~~~~~~~~~~
sreadmt.c:71:13: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   71 |             scanf("%d%f\n", &asub[lasta], &a[lasta]);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:137: sreadmt.o] Error 1
xiaoyeli commented 6 months ago

fixed.

sagitter commented 6 months ago

fixed.

Thank you.

About these ones:

sreadmt.c:62:42: error: passing argument 5 of ‘sallocateA’ from incompatible pointer type [-Wincompatible-pointer-types]
   62 |     sallocateA(*n, *nonz, nzval, rowind, colptr); /* Allocate storage */
      |                                          ^~~~~~
      |                                          |
      |                                          int **

I still need to add (as reported in GCC-14 porting notes)

#if defined __GNUC__ && __GNUC__ >= 14
#pragma GCC diagnostic warning "-Wimplicit-function-declaration"
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#pragma GCC diagnostic warning "-Wint-conversion"
#pragma GCC diagnostic warning "-Wreturn-mismatch"
#endif

to get back incompatible-pointer-types errors like warnings.

xiaoyeli commented 6 months ago

In the fixed code sreadmt.c, colptr is declared as int_t , instead of int , so the following error should not occur:

sreadmt.c:62:42: error: passing argument 5 of ‘sallocateA’ from incompatible pointer type [-Wincompatible-pointer-types] 62 sallocateA(n, nonz, nzval, rowind, colptr); / Allocate storage / ^~
int **