Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arbpoly3d fails to build with CMake #438

Open
junghans opened this issue Feb 27, 2025 · 6 comments
Open

arbpoly3d fails to build with CMake #438

junghans opened this issue Feb 27, 2025 · 6 comments

Comments

@junghans
Copy link
Contributor

/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/arbpoly3d.c:393:40: error: passing argument 4 of ‘DBPutUcdmesh’ from incompatible pointer type [-Wincompatible-pointer-types]
  393 |     DBPutUcdmesh(dbfile, "arbmesh", 3, coordnames, coords, nnodes, nzones, 0, 0, DB_FLOAT, ol);
      |                                        ^~~~~~~~~~
      |                                        |
      |                                        char **
In file included from /home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/arbpoly3d.c:52:
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/redhat-linux-build/include/silo.h:2136:82: note: expected ‘const char * const*’ but argument is of type ‘char **’
 2136 | SILO_API extern int                    DBPutUcdmesh(DBfile *, char const *, int, char const * const *, DBVCP2_t, int,
      |                                                                                  ^~~~~~~~~~~~~~~~~~~~
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/arbpoly3d.c:403:42: error: passing argument 4 of ‘DBPutUcdmesh’ from incompatible pointer type [-Wincompatible-pointer-types]
  403 |     DBPutUcdmesh(dbfile, "arbmesh_r", 3, coordnames, coords, nnodes, nzones, 0, 0, DB_FLOAT, ol);
      |                                          ^~~~~~~~~~
      |                                          |
      |                                          char **
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/redhat-linux-build/include/silo.h:2136:82: note: expected ‘const char * const*’ but argument is of type ‘char **’
 2136 | SILO_API extern int                    DBPutUcdmesh(DBfile *, char const *, int, char const * const *, DBVCP2_t, int,
      |                                                                                  ^~~~~~~~~~~~~~~~~~~~
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/arbpoly3d.c:344:21: warning: unused variable ‘nl’ [-Wunused-variable]
  344 |     int            *nl;
      |                     ^~
gmake[2]: *** [tests/CMakeFiles/arbpoly3d.dir/build.make:79: tests/CMakeFiles/arbpoly3d.dir/arbpoly3d.c.o] Error 1

build-main-1.fc43.log.zip

@junghans
Copy link
Contributor Author

And dir as well:

/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/dir.c: In function ‘main’:
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/dir.c:129:2: warning: #warning SEEMS LIKE HACK TO TEST SOMETHING [-Wcpp]
  129 | #warning SEEMS LIKE HACK TO TEST SOMETHING
      |  ^~~~~~~
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/dir.c:178:2: warning: #warning CONFIRM COPY HANDLES LINK CORRECTLY [-Wcpp]
  178 | #warning CONFIRM COPY HANDLES LINK CORRECTLY
      |  ^~~~~~~
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/dir.c:203:44: error: passing argument 4 of ‘DBPutMultimesh’ from incompatible pointer type [-Wincompatible-pointer-types]
  203 |     DBPutMultimesh(dbfile, "mmesh", nmesh, meshnames, meshtypes, NULL);
      |                                            ^~~~~~~~~
      |                                            |
      |                                            char **
In file included from /home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/dir.c:64:
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/redhat-linux-build/include/silo.h:2196:84: note: expected ‘const char * const*’ but argument is of type ‘char **’
 2196 | SILO_API extern int                    DBPutMultimesh(DBfile *, char const *, int, char const * const *, int const *,
      |                                                                                    ^~~~~~~~~~~~~~~~~~~~
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/dir.c:262:20: warning: variable ‘dbtoc’ set but not used [-Wunused-but-set-variable]
  262 |             DBtoc *dbtoc;
      |                    ^~~~~
/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests/dir.c:97:20: warning: variable ‘objname’ set but not used [-Wunused-but-set-variable]
   97 |     char          *objname = 0;
      |                    ^~~~~~~
gmake[2]: *** [tests/CMakeFiles/sdir.dir/build.make:79: tests/CMakeFiles/sdir.dir/dir.c.o] Error 1

@junghans
Copy link
Contributor Author

And I saw this error in Autotools and CMake:

make[2]: Entering directory '/home/christoph/packages/Silo/Silo-4.11.1-build/Silo-main/tests'
gcc -DHAVE_CONFIG_H -I. -I..  -I./../src/silo -I./../src/silo -I/usr/include   -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -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 -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wdeclaration-after-statement -c -o listtypes.o listtypes.c
listtypes.c: In function ‘PrintObjectComponentsType’:
listtypes.c:322:21: error: format not a string literal and no format arguments [-Werror=format-security]
  322 |                     snprintf(tmpnm, sizeof(tmpnm), &(obj->pdb_names[i][4]));
      |                     ^~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [Makefile:1815: listtypes.o] Error 1

@markcmiller86
Copy link
Member

Ok, looking at this now. I think these are fixed on the 4.11RC. But, will confirm.

@junghans
Copy link
Contributor Author

junghans commented Mar 4, 2025

Thanks, let me give it some testing.

@junghans
Copy link
Contributor Author

junghans commented Mar 4, 2025

https://koji.fedoraproject.org/koji/taskinfo?taskID=129811867:

make[4]: Leaving directory '/builddir/build/BUILD/Silo-4.11.1-build/Silo-4.11RC/src/score'
/bin/sh: line 1: ../../config/mklite: cannot execute: required file not found
make[4]: *** [Makefile:777: lite_score.h] Error 127
make[4]: *** Waiting for unfinished jobs....
make[4]: Entering directory '/builddir/build/BUILD/Silo-4.11.1-build/Silo-4.11RC/src/score'

I guess have to rerun autcreonf?

@markcmiller86
Copy link
Member

Ok, on gcc-12.2.1, I get the compilation error you mention above for dir.c but adjusting code to...

    DBPutMultimesh(dbfile, "mmesh", nmesh, (DBCAS_t) meshnames, meshtypes, NULL);

fixes and that is what I will be committing to fix.

The DBCAS_t type is related to

Silo/src/silo/silo.h.in

Lines 77 to 112 in c241460

/* Why these Void Const Pointer (VCP) typedefs? (see below)... */
typedef void const * DBVCP1_t; /* single level array */
typedef void const * DBVCP2_t; /* double level array */
typedef void const * DBVCP3_t; /* triple level array */
/* And not these...
typedef void const * DBVCP1_t; single level array
typedef void const * const * DBVCP2_t; double level array
typedef void const * const * const * DBVCP3_t; triple level array
Ideally, the later typedefs would be used in the Silo API wherever a caller
needs to pass a single, double or triple level array of arbitrary type.
However, for multi-level arrays (e.g. more than a single star*), if the caller
doesn't explicitly cast a non-void pointer to the exact type including the
const qualifiers, the later definitions create obscure and non-intuitive compiler
warnings for C callers and outright errors for C++ callers.
Basically, as counter-intuitive as it sounds neither C nor C++ compilers can handle
passing something like a 'double **' as an argument to a function expecting a
'void const * const *'.
A good reference on this issue for C is http://c-faq.com/ansi/constmismatch.html
A good reference for C++ is
http://www.embedded.com/electronics-blogs/programming-pointers/4025641/Qualifiers-in-multilevel-pointers
Therefore, we introduce the DBVCPX_t typedefs, where 'X' is 1, 2 or 3, to
indicate the number of levels in the array the Silo library is expecting the
caller to pass. Even though the typedef resolves to a 'void const *' for all
X, the underlying implementation will wind up treating it as a 'void const *' for
X=1 (e.g. DBVCP1_t), a 'void const * const *' for X=2 (e.g. DBVCP2_t), etc.
*/
/* For the char-specific case of a constant array of strings, to facilitate explicit casts */
typedef char const * const * DBCAS_t;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants