tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] arraystring, a simple C program which doesn't compile


From: Patrick Hammer
Subject: [Tinycc-devel] arraystring, a simple C program which doesn't compile
Date: Sat, 30 May 2020 19:17:37 +0000

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


reply via email to

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