code-saturne / code_saturne

code_saturne public mirror
https://www.code-saturne.org
GNU General Public License v2.0
215 stars 80 forks source link

Compilation errors with clang16 #119

Closed thierry-FreeBSD closed 11 months ago

thierry-FreeBSD commented 11 months ago

With clang16 (default for FreeBSD 14), the compilation fails with these errors:

cs_user_parameters-linear_solvers.c:201:18: warning: expression which evaluates to zero treated as a null pointer constant of type 'PetscViewer' (aka 'struct _p_PetscViewer *') [-Wnon-literal-null-conversion]
      MatView(a, PETSC_VIEWER_DEFAULT);
                 ^~~~~~~~~~~~~~~~~~~~
cs_user_parameters-linear_solvers.c:664:26: error: incompatible function pointer types passing 'void (void *, KSP)' (aka 'void (void *, struct _p_KSP *)') to parameter of type 'cs_sles_petsc_setup_hook_t *' (aka 'void (*)(void *, void *)') [-Wincompatible-function-pointer-types]
                         _petsc_p_setup_hook,
                         ^~~~~~~~~~~~~~~~~~~
../../src/alge/cs_sles_petsc.h:153:51: note: passing argument to parameter 'setup_hook' here
                     cs_sles_petsc_setup_hook_t  *setup_hook,
                                                  ^
cs_user_parameters-linear_solvers.c:715:26: error: incompatible function pointer types passing 'void (void *, KSP)' (aka 'void (void *, struct _p_KSP *)') to parameter of type 'cs_sles_petsc_setup_hook_t *' (aka 'void (*)(void *, void *)') [-Wincompatible-function-pointer-types]
                         _petsc_p_setup_hook_gamg,
                         ^~~~~~~~~~~~~~~~~~~~~~~~
../../src/alge/cs_sles_petsc.h:153:51: note: passing argument to parameter 'setup_hook' here
                     cs_sles_petsc_setup_hook_t  *setup_hook,
                                                  ^
cs_user_parameters-linear_solvers.c:767:26: error: incompatible function pointer types passing 'void (void *, KSP)' (aka 'void (void *, struct _p_KSP *)') to parameter of type 'cs_sles_petsc_setup_hook_t *' (aka 'void (*)(void *, void *)') [-Wincompatible-function-pointer-types]
                         _petsc_p_setup_hook_bamg,
                         ^~~~~~~~~~~~~~~~~~~~~~~~
../../src/alge/cs_sles_petsc.h:153:51: note: passing argument to parameter 'setup_hook' here
                     cs_sles_petsc_setup_hook_t  *setup_hook,
                                                  ^
1 warning and 3 errors generated.

As a work-around, -Wno-error=incompatible-function-pointer-types can be used.

YvanFournier commented 11 months ago

Hello,

Thanks for the bug report. I actually has the same issue 2 days ago with the Intel OneAPI compilers, so I pushed a fix using casts (part of https://github.com/code-saturne/code_saturne/commit/2006c41867d74d1b901b76302551631f630078c7, then https://github.com/code-saturne/code_saturne/commit/6c629d6d65f0c20bde136c7d2d6685e00c211ea5) on the master branch, and commit https://github.com/code-saturne/code_saturne/commit/0928bc2b3fa5abc502dc011e99765dc3c8f2aef5 on v8.0 branch.