ARM compilers 22.0.1 SVE compile clash with <netdb.h>

Hi,

compiling on a64fx with ARM 22 leads to this:

/usr/include/netdb.h:666:44: error: invalid parameter name: 'static' is a keyword
extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
^
/lustre/software/arm/compiler/22.0/arm-linux-compiler-22.0.1_Generic-AArch64_RHEL-8_aarch64-linux/lib/clang/13.0.0/include/arm_sve.h:135:14: note: expanded from macro '__ai'
#define __ai static __inline__ __attribute__((__always_inline__, __nodebug__))
^

The __ai macro in arm_sve.h is clashing with the __ai parameter.

Minimal Reproducer:

#include <arm_sve.h>
#include <netdb.h>

int main() {}

$ armclang -O3 -mcpu=a64fx ...

Parents
  • Hi tonycurtis

    Thanks for the (very) minimal reproducer!

    This has sparked a bit of discussion internally because we all thought that we knew for a fact that variables beginning with '__' were reserved for the compiler's internal use and so should not be being used in this header (from the POSIX C library correct?) However, https://en.cppreference.com/w/cpp/language/identifiers suggest that it is instead the compiler _and_ standard library that can use these. So if one were minded to call the POSIX C lib a standard library then this usage is fair.

    Regardless, it looks like the bug is due to a macro that is intended as a implementation detail in the header file being carelessly left defined, so looks like a bug we should fix. We'll try to get this fixed in a future release of Arm Compiler for Linux.

    In the meantime, as a workaround you could either:

    1) swap the order of include files and ensure __ai is not referenced in your code.

    2) Add #undef __ai after the inclusion of arm_sve.h and before the inclusion of netdb.h

    Thanks

    Rich

Reply
  • Hi tonycurtis

    Thanks for the (very) minimal reproducer!

    This has sparked a bit of discussion internally because we all thought that we knew for a fact that variables beginning with '__' were reserved for the compiler's internal use and so should not be being used in this header (from the POSIX C library correct?) However, https://en.cppreference.com/w/cpp/language/identifiers suggest that it is instead the compiler _and_ standard library that can use these. So if one were minded to call the POSIX C lib a standard library then this usage is fair.

    Regardless, it looks like the bug is due to a macro that is intended as a implementation detail in the header file being carelessly left defined, so looks like a bug we should fix. We'll try to get this fixed in a future release of Arm Compiler for Linux.

    In the meantime, as a workaround you could either:

    1) swap the order of include files and ensure __ai is not referenced in your code.

    2) Add #undef __ai after the inclusion of arm_sve.h and before the inclusion of netdb.h

    Thanks

    Rich

Children