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

Failed compilation with -Wincompatible-pointer-types error #340

Closed
runlevel5 opened this issue Aug 19, 2024 · 0 comments · Fixed by #341
Closed

Failed compilation with -Wincompatible-pointer-types error #340

runlevel5 opened this issue Aug 19, 2024 · 0 comments · Fixed by #341

Comments

@runlevel5
Copy link
Contributor

In file included from /home/tle/Work/openmohaa/code/qcommon/../script/../qcommon/listener.h:29,
                 from /home/tle/Work/openmohaa/code/qcommon/../script/scriptvariable.h:27,
                 from /home/tle/Work/openmohaa/code/qcommon/listener.cpp:25:
/home/tle/Work/openmohaa/code/qcommon/../script/../qcommon/con_arrayset.h: In member function ‘void con_arrayset<k, v>::resize(int) [with k = command_t; v = command_t]’:
/home/tle/Work/openmohaa/code/qcommon/../script/../qcommon/con_arrayset.h:195:9: warning: ‘void operator delete [](void*)’ called on pointer ‘*this.con_arrayset<command_t, command_t>::reverseTable’ with nonzero offset 8 [-Wfree-nonheap-object]
  195 |         delete[] oldReverseTable;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
[ 84%] Building C object CMakeFiles/openmohaa.dir/code/qcommon/cm_test.c.o
[ 84%] Building CXX object CMakeFiles/openmohaa.dir/code/qcommon/cm_trace_lbd.cpp.o
[ 84%] Building C object CMakeFiles/openmohaa.dir/code/qcommon/cm_trace.c.o
[ 84%] Building CXX object CMakeFiles/openmohaa.dir/code/qcommon/cm_trace_obfuscation.cpp.o
/home/tle/Work/openmohaa/code/script/scriptvariable.cpp: In destructor ‘ScriptConstArrayHolder::~ScriptConstArrayHolder()’:
/home/tle/Work/openmohaa/code/script/scriptvariable.cpp:334:18: warning: ‘void operator delete [](void*, std::size_t)’ called on pointer ‘*this.ScriptConstArrayHolder::constArrayValue’ with nonzero offset 8 [-Wfree-nonheap-object]
  334 |         delete[] offset;
      |                  ^~~~~~
/home/tle/Work/openmohaa/code/sys/sys_unix.c: In function ‘Sys_ListFiles’:
/home/tle/Work/openmohaa/code/sys/sys_unix.c:418:55: warning: passing argument 3 of ‘Sys_ListFilteredFiles’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  418 |                 Sys_ListFilteredFiles( directory, "", filter, list, &nfiles );
      |                                                       ^~~~~~
/home/tle/Work/openmohaa/code/sys/sys_unix.c:340:71: note: expected ‘char *’ but argument is of type ‘const char *’
  340 | void Sys_ListFilteredFiles( const char *basedir, char *subdirs, char *filter, char **list, int *numfiles )
      |                                                                 ~~~~~~^~~~~~
[ 84%] Building C object CMakeFiles/openmohaa.dir/code/qcommon/cmd.c.o
[ 85%] Building CXX object CMakeFiles/openmohaa.dir/code/qcommon/common.cpp.o
[ 85%] Building C object CMakeFiles/openmohaa.dir/code/qcommon/crc.c.o
[ 85%] Building C object CMakeFiles/openmohaa.dir/code/qcommon/cvar.c.o
[ 85%] Building CXX object CMakeFiles/openmohaa.dir/code/qcommon/files.cpp.o
/home/tle/Work/openmohaa/code/server/sv_ccmds.c: In function ‘SV_ArchiveLevelFile’:
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1881:42: error: passing argument 2 of ‘ge->ReadLevel’ from incompatible pointer type [-Wincompatible-pointer-types]
 1881 |                 if (!ge->ReadLevel(name, &cls.savedCgameState, &cls.savedCgameStateSize)) {
      |                                          ^~~~~~~~~~~~~~~~~~~~
      |                                          |
      |                                          void **
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1881:42: note: expected ‘byte **’ {aka ‘unsigned char **’} but argument is of type ‘void **’
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1881:64: error: passing argument 3 of ‘ge->ReadLevel’ from incompatible pointer type [-Wincompatible-pointer-types]
 1881 |                 if (!ge->ReadLevel(name, &cls.savedCgameState, &cls.savedCgameStateSize)) {
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                |
      |                                                                size_t * {aka long unsigned int *}
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1881:64: note: expected ‘int *’ but argument is of type ‘size_t *’ {aka ‘long unsigned int *’}
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1904:40: error: passing argument 3 of ‘ge->WriteLevel’ from incompatible pointer type [-Wincompatible-pointer-types]
 1904 |         ge->WriteLevel(name, autosave, &cls.savedCgameState, &cls.savedCgameStateSize);
      |                                        ^~~~~~~~~~~~~~~~~~~~
      |                                        |
      |                                        void **
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1904:40: note: expected ‘byte **’ {aka ‘unsigned char **’} but argument is of type ‘void **’
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1904:62: error: passing argument 4 of ‘ge->WriteLevel’ from incompatible pointer type [-Wincompatible-pointer-types]
 1904 |         ge->WriteLevel(name, autosave, &cls.savedCgameState, &cls.savedCgameStateSize);
      |                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                                              |
      |                                                              size_t * {aka long unsigned int *}
/home/tle/Work/openmohaa/code/server/sv_ccmds.c:1904:62: note: expected ‘int *’ but argument is of type ‘size_t *’ {aka ‘long unsigned int *’}
make[2]: *** [CMakeFiles/openmohaa.dir/build.make:412: CMakeFiles/openmohaa.dir/code/server/sv_ccmds.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 85%] Building CXX object CMakeFiles/openmohaa.dir/code/qcommon/huffman.cpp.o
/home/tle/Work/openmohaa/code/sys/sys_main.c: In function ‘Sys_PIDFileName’:
/home/tle/Work/openmohaa/code/sys/sys_main.c:183:24: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  183 |                 return va( "%s/%s/%s", homePath, gamedir, PID_FILENAME );
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 85%] Building C object CMakeFiles/openmohaa.dir/code/qcommon/md4.c.o
[ 85%] Building C object CMakeFiles/openmohaa.dir/code/qcommon/md5.c.o
/home/tle/Work/openmohaa/code/qcommon/cvar.c: In function ‘Cvar_CompleteCvarName’:
/home/tle/Work/openmohaa/code/qcommon/cvar.c:1609:43: warning: passing argument 1 of ‘Com_SkipTokens’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 1609 |                 char *p = Com_SkipTokens( args, 1, " " );
      |                                           ^~~~
In file included from /home/tle/Work/openmohaa/code/qcommon/cvar.c:24:
/home/tle/Work/openmohaa/code/qcommon/q_shared.h:1171:29: note: expected ‘char *’ but argument is of type ‘const char *’
 1171 | char *Com_SkipTokens( char *s, int numTokens, const char *sep );
      |                       ~~~~~~^
/home/tle/Work/openmohaa/code/qcommon/files.cpp: In function ‘int check_filecase(char*)’:
/home/tle/Work/openmohaa/code/qcommon/files.cpp:548:15: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  548 |     basedir = ".";
      |               ^~~
/home/tle/Work/openmohaa/code/qcommon/common.cpp: In function ‘void Com_Error(int, const char*, ...)’:
/home/tle/Work/openmohaa/code/qcommon/common.cpp:451:1: warning: ‘noreturn’ function does return
  451 | }
      | ^
/home/tle/Work/openmohaa/code/qcommon/common.cpp: In function ‘void Com_Quit_f()’:
/home/tle/Work/openmohaa/code/qcommon/common.cpp:478:1: warning: ‘noreturn’ function does return
  478 | }
      | ^
make[1]: *** [CMakeFiles/Makefile2:339: CMakeFiles/openmohaa.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/tle/Work/openmohaa/code/qcommon/../script/../qcommon/listener.h:29,
                 from /home/tle/Work/openmohaa/code/qcommon/../script/scriptvariable.h:27,
                 from /home/tle/Work/openmohaa/code/qcommon/listener.cpp:25:
/home/tle/Work/openmohaa/code/qcommon/../script/../qcommon/con_arrayset.h: In member function ‘void con_arrayset<k, v>::resize(int) [with k = command_t; v = command_t]’:
/home/tle/Work/openmohaa/code/qcommon/../script/../qcommon/con_arrayset.h:195:9: warning: ‘void operator delete [](void*)’ called on pointer ‘*this.con_arrayset<command_t, command_t>::reverseTable’ with nonzero offset 8 [-Wfree-nonheap-object]
  195 |         delete[] oldReverseTable;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
[ 85%] Linking CXX shared library gameppc64el.so
[ 85%] Built target fgame
make: *** [Makefile:136: all] Error 2
Exit 2

My machine spec is:

# Fedora 40 ppc64le
$ gcc --version
gcc (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1)

It's seems to me this issue is impacted by the strict default settings of GCC. I will see if I could get a PR to address the issue.

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

Successfully merging a pull request may close this issue.

1 participant