Hi!

First, amazing work with tcc. I however found two issues with it, programs
which work with Clang, gcc etc., but not with tcc. Program1 tries to use a
char from a string defined with #define:

#include <stdio.h>
#define abc "abc"

int main(void)
{
    char a[2] = { abc[0], 0 };
    puts(a);
    return 0;
}

Output:
arraystring.c:6: warning: initializer-string for array is too long
arraystring.c:6: error: '}' expected (got "[")

Interestingly this program works when a parenthesis is put around abc[0]:
char a[2] = { (abc[0]), 0 };
Alternatively, it also works if the parenthesis is around the defined
string instead:
#define abc ("abc")
which can also be done at usage level:
char a[2] = { (abc)[0], 0 };

so maybe it's an issue with the parser?

Attached are all variations, of which arraystring.c causes the error.
I will put the second simple program which doesn't compile in an extra
thread.

Best regards,
Patrick

Attachment: arraystring.c
Description: Binary data

Attachment: arraystring_workaround.c
Description: Binary data

Attachment: arraystring_workaround2.c
Description: Binary data

Attachment: arraystring_workaround3.c
Description: Binary data

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

Reply via email to