FYI, I hve reported the following bug:
https://savannah.nongnu.org/bugs/?58606
When the evaluation of a __builtin_constant_p argument would have
a side effect, this argument should not be regarded as a constant
because in practice, it may be used in an expression that evaluates
the argument several times (for instance, think of a macro to compute
min(x,y), avoiding a function call when x and y are constants). The
current tcc (8fb8d88 in mob branch) fails to behave correctly, as
shown on the following example.
#include <stdio.h>
#define FOO(X) (__builtin_constant_p (X) ? ((X), (X), (X)) : (X))
int main (void)
{
int c = 0, i;
i = FOO ((c++, 7));
printf ("%d %d\n", c, i);
return c == 1 && i == 7 ? 0 : 1;
}
With GCC and Clang, I get "1 7" since FOO ((c++, 7)) is replaced
by ((c++, 7)).
But with tcc, I get "3 7".
--
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel