~emersion/basu#18: 
Build failure with GCC 12

Meson and Muon seem to add -Wpedantic automatically.

With GCC 12, even with -std=gnu99, -Wpedantic complains about %m in format strings, __PRETTY_FUNCTION__, braces inside expressions, etc.; and it makes some of these into errors.

Workaround:

--- a/meson.build
+++ b/meson.build
@@ -61,6 +61,9 @@ possible_cc_flags = [
         # work-around for gcc 7.1 turning this on on its own.
         '-Wno-error=nonnull',

+        # work-around -Wpedantic added by meson/muon
+        '-Wno-pedantic',
+
         # Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with
         # optimizations enabled, producing essentially false positives.
         '-Wno-maybe-uninitialized',
Status
RESOLVED CLOSED
Submitter
~ismael
Assigned to
No-one
Submitted
1 year, 6 months ago
Updated
1 year, 5 months ago
Labels
No labels applied.

~ismael 1 year, 6 months ago

Error log:

samu: job failed: cc -std=gnu99 -g -Og -Wpedantic -Wextra -Wall -Wextra -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noretu
rn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmiss
ing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-unused-par
ameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-format-nonliteral -Wno-error=nonnull -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-ali
asing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -fPIE -ffunction-sections -fdata-sections -Werror=shadow -include /home/ismael/projects/libs/basu/build/config.h -I sr
c/test -I ../src/test -I src/basic -I ../src/basic -I src/systemd -I ../src/systemd -I ../src/libsystemd/sd-bus -I ../src/libsystemd/sd-daemon -I ../src/libsystemd/sd-id128 -pthread -fpic -MD -MQ src/test/liblibte
st.a.p/tests.c.o -MF src/test/liblibtest.a.p/tests.c.o.d -o src/test/liblibtest.a.p/tests.c.o -c ../src/test/tests.c
In file included from ../src/basic/macro.h:381,
                 from ../src/basic/util.h:19,
                 from ../src/test/tests.c:4:
../src/basic/util.h: In function 'qsort_safe':
../src/basic/macro.h:208:72: warning: ISO C does not support '__PRETTY_FUNCTION__' predefined identifier [-Wpedantic]
  208 |                         log_assert_failed(message, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
      |                                                                        ^~~~~~~~~~~~~~~~~~~
../src/basic/log.h:58:52: note: in definition of macro 'log_assert_failed'
   58 |         log_assert_failed_realm(LOG_REALM, (text), __VA_ARGS__)
      |                                                    ^~~~~~~~~~~
../src/basic/macro.h:224:22: note: in expansion of macro 'assert_message_se'
  224 | #define assert(expr) assert_message_se(expr, #expr)
      |                      ^~~~~~~~~~~~~~~~~
../src/basic/util.h:50:9: note: in expansion of macro 'assert'
   50 |         assert(base);
      |         ^~~~~~
../src/basic/util.h: In function 'memcpy_safe':
../src/basic/macro.h:208:72: warning: ISO C does not support '__PRETTY_FUNCTION__' predefined identifier [-Wpedantic]
  208 |                         log_assert_failed(message, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
      |                                                                        ^~~~~~~~~~~~~~~~~~~
../src/basic/log.h:58:52: note: in definition of macro 'log_assert_failed'
   58 |         log_assert_failed_realm(LOG_REALM, (text), __VA_ARGS__)
      |                                                    ^~~~~~~~~~~
../src/basic/macro.h:224:22: note: in expansion of macro 'assert_message_se'
  224 | #define assert(expr) assert_message_se(expr, #expr)
      |                      ^~~~~~~~~~~~~~~~~
../src/basic/util.h:66:9: note: in expansion of macro 'assert'
   66 |         assert(src);
      |         ^~~~~~
../src/basic/util.h: In function 'log2u':
../src/basic/macro.h:208:72: warning: ISO C does not support '__PRETTY_FUNCTION__' predefined identifier [-Wpedantic]
  208 |                         log_assert_failed(message, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
      |                                                                        ^~~~~~~~~~~~~~~~~~~
../src/basic/log.h:58:52: note: in definition of macro 'log_assert_failed'
   58 |         log_assert_failed_realm(LOG_REALM, (text), __VA_ARGS__)
      |                                                    ^~~~~~~~~~~
../src/basic/macro.h:224:22: note: in expansion of macro 'assert_message_se'
  224 | #define assert(expr) assert_message_se(expr, #expr)
      |                      ^~~~~~~~~~~~~~~~~
../src/basic/util.h:92:9: note: in expansion of macro 'assert'
   92 |         assert(x > 0);
      |         ^~~~~~
../src/basic/util.h: In function 'log2u_round_up':
../src/basic/macro.h:208:72: warning: ISO C does not support '__PRETTY_FUNCTION__' predefined identifier [-Wpedantic]
  208 |                         log_assert_failed(message, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
      |                                                                        ^~~~~~~~~~~~~~~~~~~
../src/basic/log.h:58:52: note: in definition of macro 'log_assert_failed'
   58 |         log_assert_failed_realm(LOG_REALM, (text), __VA_ARGS__)
      |                                                    ^~~~~~~~~~~
../src/basic/macro.h:224:22: note: in expansion of macro 'assert_message_se'
  224 | #define assert(expr) assert_message_se(expr, #expr)
      |                      ^~~~~~~~~~~~~~~~~
../src/basic/util.h:98:9: note: in expansion of macro 'assert'
   98 |         assert(x > 0);
      |         ^~~~~~
../src/test/tests.c: In function 'log_tests_skipped':
../src/basic/log.h:80:9: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
   80 |         ({                                                              \
      |         ^
../src/basic/log.h:89:9: note: in expansion of macro 'log_full_errno_realm'
   89 |         log_full_errno_realm(LOG_REALM, (level), (error), __VA_ARGS__)
      |         ^~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:91:30: note: in expansion of macro 'log_full_errno'
   91 | #define log_full(level, ...) log_full_errno((level), 0, __VA_ARGS__)
      |                              ^~~~~~~~~~~~~~
../src/basic/log.h:96:28: note: in expansion of macro 'log_full'
   96 | #define log_notice(...)    log_full(LOG_NOTICE,  __VA_ARGS__)
      |                            ^~~~~~~~
../src/test/tests.c:19:9: note: in expansion of macro 'log_notice'
   19 |         log_notice("%s: %s, skipping tests.",
      |         ^~~~~~~~~~
../src/test/tests.c: In function 'log_tests_skipped_errno':
../src/test/tests.c:25:29: error: ISO C does not support the '%m' gnu_printf format [-Werror=format=]
   25 |         log_notice_errno(r, "%s: %s, skipping tests: %m",
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:84:76: note: in definition of macro 'log_full_errno_realm'
   84 |                                              __FILE__, __LINE__, __func__, __VA_ARGS__) \
      |                                                                            ^~~~~~~~~~~
../src/basic/log.h:102:41: note: in expansion of macro 'log_full_errno'
  102 | #define log_notice_errno(error, ...)    log_full_errno(LOG_NOTICE,  error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/test/tests.c:25:9: note: in expansion of macro 'log_notice_errno'
   25 |         log_notice_errno(r, "%s: %s, skipping tests: %m",
      |         ^~~~~~~~~~~~~~~~
../src/test/tests.c:25:55: note: format string is defined here
   25 |         log_notice_errno(r, "%s: %s, skipping tests: %m",
      |                                                       ^
../src/basic/log.h:80:9: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
   80 |         ({                                                              \
      |         ^
../src/basic/log.h:89:9: note: in expansion of macro 'log_full_errno_realm'
   89 |         log_full_errno_realm(LOG_REALM, (level), (error), __VA_ARGS__)
      |         ^~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:102:41: note: in expansion of macro 'log_full_errno'
  102 | #define log_notice_errno(error, ...)    log_full_errno(LOG_NOTICE,  error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/test/tests.c:25:9: note: in expansion of macro 'log_notice_errno'
   25 |         log_notice_errno(r, "%s: %s, skipping tests: %m",
      |         ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

~emersion REPORTED CLOSED 1 year, 5 months ago

Ismael Luceno referenced this ticket in commit f207324.

Register here or Log in to comment, or comment via email.