Can't use _Generic to determine if expression is constant

This code should work for any C11-compliant compiler:

#include <assert.h>
#include <stddef.h>
#include <stdint.h>

#define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)

int main(void) {
  assert(HEDLEY__IS_CONSTEXPR(1729) == 1);

  return 0;
}

However, it fails with PGI:

$ pgcc -c11 -oconstant pgi-constant.c
PGC-S-0155-No appropriate _Generic selection expression found  (pgi-constant.c: 8)
PGC-S-0000-Internal compiler error. mkexpr: bad id       0  (pgi-constant.c: 8)
PGC-S-0000-Internal compiler error. mkexpr: bad id       0  (pgi-constant.c: 8)
PGC-S-0103-Illegal operand types for comparison operator (pgi-constant.c: 8)
PGC/x86-64 Linux 18.4-0: compilation completed with severe errors

There is more information about why/how this (should) work at https://stackoverflow.com/q/49480442/501126

Hi nemequ,

Thanks for the report! I was able to recreate the failure here and have filed an issue report (TPR#25574). I’ve sent it to our compiler engineers for further investigation.

Best Regards,
Mat

For anyone coming to this thread with a similar problem: the issue is resolved with release 19.5+