[gnutls-devel] GnuTLS | audit: crau: fix compilation with gcc < 11 (!2045)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Sun Nov 23 18:19:36 CET 2025



Julien Olivain created a merge request: https://gitlab.com/gnutls/gnutls/-/merge_requests/2045

Project:Branches: jolivain/gnutls:fix_crau_with_old_gcc to gnutls/gnutls:master
Author:   Julien Olivain



audit: crau: fix compilation with gcc < 11

If the CRAU_MAYBE_UNUSED macro is unset, the crau.h file tries to
automatically detect an appropriate value for it.

This autodetection is using the cpp special operator
`__has_c_attribute` [1], introduced in gcc 11 [2].

When compiling with a gcc older than version 11, the compilation fails
with the error:

    In file included from audit.h:22,
                     from audit.c:26:
    crau/crau.h:255:23: error: missing binary operator before token "("
         __has_c_attribute (__maybe_unused__)
                           ^

This has been observed, for example, in Rocky Linux 8.10, which
contains a gcc v8.5.0.

The issue happens because the test for the `__has_c_attribute`
availability and the test for the `__maybe_unused__` attribute
are in the same directive. Those tests should be separated in
two different directives, following the same logic described in
the `__has_builtin` documentation [3].

This issue was found in Buildroot, after updating gnutls to
version 3.8.11 in [4].

This commit fixes the issue by splitting the test in two.

[1] https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fc_005fattribute.html
[2] https://gcc.gnu.org/gcc-11/changes.html#c
[3] https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fbuiltin.html
[4] https://gitlab.com/buildroot.org/buildroot/-/commit/81dbfe1c2ae848b4eb1f896198d13455df50e548

Reported-by: Neal Frager <neal.frager at amd.com>
Signed-off-by: Julien Olivain <ju.o at free.fr>

## Checklist
 * [ ] Commits have `Signed-off-by:` with name/author being identical to the commit author
 * [ ] Code modified for feature
 * [ ] Test suite updated with functionality tests
 * [ ] Test suite updated with negative tests
 * [ ] Documentation updated / NEWS entry present (for non-trivial changes)

## Reviewer's checklist:
 * [ ] Any issues marked for closing are addressed
 * [ ] There is a test suite reasonably covering new functionality or modifications
 * [ ] Function naming, parameters, return values, types, etc., are consistent and according to `CONTRIBUTION.md`
 * [ ] This feature/change has adequate documentation added
 * [ ] No obvious mistakes in the code

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/2045
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20251123/d8038b8f/attachment-0001.html>


More information about the Gnutls-devel mailing list