tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Integer constant expression bug


From: grischka
Subject: Re: [Tinycc-devel] Integer constant expression bug
Date: Sun, 20 Jun 2021 01:41:07 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Elijah Stone wrote:
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

The clause is correctly implemented, it's just that for tcc there is no
difference between 0 and the optimized result of X*0.

-- gr

 -E

On Thu, 20 May 2021, Petr Skocik wrote:

Hi.

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

Examples:

#define CEXPR_EH(X) _Generic((1? (void *) ((!!(X))*0ll) : (int *) 0),
int*: 1, void*: 0)
//ok
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),"");  }

Regards,

Petr S.


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

------------------------------------------------------------------------

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




reply via email to

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