[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Integer constant expression bug

From: Elijah Stone
Subject: Re: [Tinycc-devel] Integer constant expression bug
Date: Sat, 19 Jun 2021 10:21:21 -0700 (PDT)

Actually, the problem is with the CEXPR_EH macro; it always returns 1.

If I replace the definition with '#define CEXPR_EH __builtin_constant_p', all of your tests pass.

I guess the problem is that the behaviour of this clause (from 6.5.15p6) is not correctly implemented:

if one operand is a null pointer constant, the result has the type of the other operand


On Thu, 20 May 2021, Petr Skocik wrote:


Not sure if this is news but tinycc treats certain values which are
definitely not integer constant expressions as if they were.


#define CEXPR_EH(X) _Generic((1? (void *) ((!!(X))*0ll) : (int *) 0),
int*: 1, void*: 0)
void should_be_ok1(void) { enum{x=0};  _Static_assert(CEXPR_EH(x),"");  }

//each of these fails on tinycc
void should_be_ok2(void) {  extern int x; 
_Static_assert(!CEXPR_EH(x),"");  }
void should_be_ok3(void) {  int x=0;  _Static_assert(!CEXPR_EH(x),"");  }
void should_be_ok4(int x) {  _Static_assert(!CEXPR_EH(x),"");  }
void should_be_ok5(void) {  double x=0;  _Static_assert(!CEXPR_EH(x),"");  }
void should_be_ok6(void) {  extern double y; 
_Static_assert(!CEXPR_EH(y),"");  }
void should_be_ok7(void) {  char *x=0 ;  _Static_assert(!CEXPR_EH(x),"");  }
void should_be_ok8(char *x) { _Static_assert(!CEXPR_EH(x),"");  }


Petr S.

Tinycc-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]