The following file causes the error Internal error: cannot get source line from database
using both cscope -L0 ".*" example.c
and cscope -L3 ".*" example.c
:
#define Y(a) Y(a) #define X(a) do { }while(0) int main(void){}
I am using cscope 15.9. I originally had malfunctions on math.c (attached) from the linux kernel; the file above is the result of isolating the problematic c code.
Unlike #274 no CMake files are involved, and unlike #284 the -q flag is not being used and only a single file is needed to reproduce. This bug appears to be more tolerant to whitespace changes than #271,
Here is the example file that I used.
This actually is a problem in the scanner, first. The Y(a) macro call is mistaken for a function definition, with the braces in the #define X(a) line as its function body, and everything between as the (K&R-style) argument definition list. Then as the parser goes on it finds #define X(a) as a macro definition. And then inside that, it mistakes "}while(0)" as a function call.
The query/output routine later barfs as it tries to find the beginning of the line that function call was in, because the database is slightly ill-formed.
The test case is actually rather dependent on white-space change in one tell-tale way, which may both explain why this wasn't found much more often, and offer a possible work-around. Inserting a blank into the rather unusually spelled definiton of X(a) fixes it:
Last edit: Hans-Bernhard Broeker 2021-02-08