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&gt;

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



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



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


Fix:


According to your decision.









837806295
837806...@qq.com






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

Reply via email to