Skip to content

Tests fail to compile with GCC 14 #187

@eli-schwartz

Description

@eli-schwartz

https://wiki.gentoo.org/wiki/Modern_C_porting#How_do_I_reproduce_these_bugs.3F

GCC 14 and clang 16 have started to error on invalid C code that was removed from the standard in c99 or even earlier. Historically, compilers accepted this code even though it was invalid in an effort to avoid breaking really old codebases. Due to the passing of time and an increasing understanding of just how dangerous this invalid code is, that leniency is going away.

Note that this is not cosmetic. It is undefined behavior and compilers will (increasingly) optimize it in weird and wonderful ways that break the original intention of the code. It will also obviously mean that the code cannot be built on newer systems with updated compilers.

An easy way to reproduce the problem even on older compiler versions is to build with the following *FLAGS:

-Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types

Lurch itself builds successfully, but it fails to build the testsuite:

cc -pipe -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -std=c11 -Wall -g -Wstrict-overflow -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libpurple -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/libomemo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/axc -I/usr/include/signal -I/usr/include/signal -I./headers/jabber -O0 -c ./test/test_lurch_util.c -o build/test_lurch_util.o
./test/test_lurch_util.c: In function ‘test_lurch_util_axc_log_func_error’:
./test/test_lurch_util.c:69:5: error: implicit declaration of function ‘lurch_util_axc_log_func’ [-Werror=implicit-function-declaration]
   69 |     lurch_util_axc_log_func(AXC_LOG_ERROR, "test", 4, axc_ctx_p);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make: *** [Makefile:154: build/test_lurch_util.o] Error 1
 * ERROR: x11-plugins/lurch-0.7.0-r1::gentoo failed (test phase):

Full build log: build.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions