Hello tinycc-devel list,
Using 330c01bfc6fa6721fd455911a966bce041df31d8 version of tcc, I hit a
bug while trying to compile stuff using the '-b' option. Here is a
reduced test case:
------8< cut here 8<-------
// reduced test case for -b bug with ternary operator
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct token {
char *toketext;
};
struct tree_node {
struct token *leaftoken;
};
int main(void) {
struct tree_node *node=(struct tree_node *)malloc(sizeof(struct tree_node));
node->leaftoken=(struct token *)malloc(sizeof(struct token));
node->leaftoken->toketext=strdup("whatever");
// the ternary operator will cause
// 'error: unhandled size when dereferencing bounded pointer'
// when you compile with tcc and '-b' option
// true even for 330c01bfc6fa6721fd455911a966bce041df31d8
// set argument to if to 1 to see error, set it to 0 to see pass
#if 1
fprintf(stderr, "data->leaftoken->toketext = '%s'\n",
!(node->leaftoken->toketext) ? "null" : node->leaftoken->toketext);
#else
// but this works
fprintf(stderr, "data->leaftoken->toketext = '%s'\n",
node->leaftoken->toketext ? node->leaftoken->toketext : "null");
#endif
return EXIT_SUCCESS;
}
------8< cut here 8<-------
When compiled without '-b' option, both ways to do it run and work fine.
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel