[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks
From: |
Vincent Lefevre |
Subject: |
Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks |
Date: |
Tue, 12 Jul 2022 02:44:50 +0200 |
User-agent: |
Mutt/2.2.6+26 (7d9df177) vl-149028 (2022-07-06) |
On 2022-07-12 06:56:34 +0800, Ziyao wrote:
> > while with tcc:
> >
> > zira:~> tcc -E err.c
> > # 1 "err.c"
> > # 1 "<command line>" 1
> > # 2 "err.c" 2
> >
> >
> > "
> > FOO
> > "
> > "FOO"
> >
> > which makes more sense as an extension, IMHO. But tcc doesn't give
> > any diagnostic there, and I think that this is incorrect.
>
> It seems that TinyCC parses the first three lines as a string
> literature,does't it?
Yes, tcc ends the string literal only at a terminating " character
and seems to accept anything before it. This can be seen on
#define FOO bar
"
FOO
which gives an error
err.c:4: error: missing terminating " character
at line 4.
> But according to C99 standard,
>
> string-literal:
> " s-char-sequenceopt "
> L" s-char-sequenceopt "
> s-char-sequence:
> s-char
> s-char-sequence s-char
> s-char:
> any member of the source character set except the double-quote ",
> backslash \, or new-line character
> escape-sequence
>
> New-line character cannot be included in a string literature.
For this reason, this violates a syntax rule, and the C standard
says "A conforming implementation shall produce at least one
diagnostic message [...] if a preprocessing translation unit
or translation unit contains a violation of any syntax rule
or constraint [...]". That's why I said that there should be
a diagnostic. So the missing diagnostic with tcc is a bug.
If the program is not rejected, the behavior is undefined.
--
Vincent Lefèvre <vincent@vinc17.net> - 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] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Domingo Alvarez Duarte, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks,
Vincent Lefevre <=
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/12
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, grischka, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, grischka, 2022/07/15
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, grischka, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/13