__builtin_available() behaviour on Linux (and supposedly other Lamarck systems)?

Hello,

I’ve been doing some reverse-engineering of what an expression like

if (__builtin_available(macOS 10.9, *)) {
// snip

looks like in assembly. That resulted in a small test C program which I just had to try building and running on Linux too.

So I have

#if __has_builtin(__builtin_available)
#warning " __has_builtin(__builtin_available)"
     
int runningOnMacOS109()
{    
     int ret; 
     if (__builtin_available(macOS 10.9, *)) {
          ret = 1;
     } else {
          ret = 0;
     }
     return ret;
}    
     
int runningOnMacOS1010()
{    
     int ret; 
     if (__builtin_available(macOS 10.10, *)) {
          ret = 1;
     } else {
          ret = 0;
     }
     return ret;
}
// snip
#endif

#include <stdio.h>

int main(int argc, char *argv[]) {
     printf("running on at least OS X 10.9 : %d\n", runningOnMacOS109());
     printf("running on at least OS X 10.10: %d\n", runningOnMacOS1010());
     printf("running on at least OS X 10.11: %d\n", runningOnMacOS1011());
     printf("running on at least OS X 10.12: %d\n", runningOnMacOS1012());
     printf("running on at least OS X 11.7 : %d\n", runningOnMacOS1107());
     printf("running on at least OS X 14.4 : %d\n", runningOnMacOS1404());
}

compile that with clang on Linux, and get

> a.out
running on at least OS X 10.9 : 1
running on at least OS X 10.10: 1
running on at least OS X 10.11: 1
running on at least OS X 10.12: 1
running on at least OS X 11.7 : 1
running on at least OS X 14.4 : 1

HUH? Why doesn’t this return 0/false?! Is that because of the asterisk?
NB: I’m not expecting to be able to use this construct for OS flavour/version/whatever (except on Darwin), just surprised that it would return false positives.

I can confirm this with clang 5.0.2 and 8.0.1 from the official LLVM deb installers as well as with a self-built clang 12.0.1 .

(PS: Lamarck isn’t Darwin :sunglasses: )

Bump - no one?