tinycc-devel
[Top][All Lists]
Advanced

[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 16:17:35 +0200
User-agent: Mutt/2.2.6+26 (7d9df177) vl-149028 (2022-07-06)

On 2022-07-11 21:57:45 +0800, Ziyao wrote:
> The simpliest example is like below:
> 
> #if 0
> "
> #if 0
> "
> #endif
> #endif

Going back to this example, even if GCC doesn't give an error,
consider a slight variation:

#if 0
R"-(
#if 0
)-"
#endif
#endif

This time, one gets an error with gcc (default GNU dialect or C++):

err.c:6:2: error: #endif without #if
    6 | #endif
      |  ^~~~~

And the following code

#if 0
R"-(
#if 0
)-"
#endif

does not give any warning or error (the behavior is different
if one provides an option like -std=c99 to follow ISO C99).

This is due to the use of a "raw string literal", specified
by C++11 (and this can also be regarded as a C extension),
which allows newline characters.

This shows that you cannot ignore parsing in a skipped block.

-- 
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)



reply via email to

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