Skip to content

[PAC] ptrauth.h triggers -Wgnu-statement-expression-from-macro-expansion #171461

@EliaGeretto

Description

@EliaGeretto

When including ptrauth.h without using -fptrauth-intrinsics, -Wgnu-statement-expression-from-macro-expansion is triggered. That warning is part of -Wpedantic.

The issue is caused by the use of GNU statement expressions in the following macro:

#define ptrauth_strip(__value, __key) \
({ \
(void)__key; \
__value; \
})

A possible fix is relying on the comma operator:

 #define ptrauth_strip(__value, __key)                                          \
   (                                                                            \
     (void)__key,                                                               \
     __value                                                                    \
   )

Reproducer:

#include <ptrauth.h>

int main(void) {
    ptrauth_strip(&main, ptrauth_key_function_pointer);
    return 0;
}

Build with: clang -Wpedantic repro.c

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions