tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Report a Bug about Parsing #ifdef, #ifndef and #else Line


From: 837806295
Subject: [Tinycc-devel] Report a Bug about Parsing #ifdef, #ifndef and #else Line
Date: Sun, 31 Mar 2024 23:43:34 +0800

Hello!

Report a Bug about Parsing #ifdef, #ifndef and #else Line.

--------------------------------------------------------------------------------

Bug info:

File: tccpp.c
Function: preprocess, preprocess_skip
Line: 1813, 1816, 1842


--------------------------------------------------------------------------------

Test code:


#include <stdio.h>

#define Test

int main(int argc, const char **argv)
{
#ifndef Test #else
printf("Hello, Test\n");
#endif

printf("Hello, World\n");

return 0;
}


Hello, Test Hello, World

--------------------------------------------------------------------------------

Problem:


In the preprocess function, when analyzing lines containing preprocessor 
directives such as #ifndef#ifdef, and #else, the entire line is not 
being fully read. When the conditions for a branch are not met and the 
preprocess_skip function is invoked to skip over subsequent code, 
issues arise because preprocess_skip assumes it is starting at the 
beginning of a new line. 


As in the code above, it is possible to insert a large amount of whitespace 
before an #else directive on a single line. If the #else is not properly 
detected due to this issue, it can cause confusion and make it difficult 
for someone to identify the root cause.

--------------------------------------------------------------------------------

Fix:

According to your decision.




837806295
837806295@qq.com
 

reply via email to

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