simplecpp
simplecpp copied to clipboard
wrong location for tokens
Reported in the cppcheck forum: https://sourceforge.net/p/cppcheck/discussion/general/thread/9c0ae79e38/?limit=25
Example code:
int main()
{
char* ptr = 0;
#line 16 "main.sc"
{
#line 12 "main.sc"
struct sqlexd sqlstm;
}
#line 16 "main.sc"
strcpy(ptr, "bad");
}
Cppcheck reports this:
main.sc:21:12: error: Null pointer dereference: ptr [nullPointer]
The linenumber should not be 21 it should be 16.
Subsequent #line markers are ignored.
1: int main ( )
2: {
3: char * ptr = 0 ;
#line 16 "main.sc"
16: {
17:
18: struct sqlexd sqlstm ;
19: }
20:
21: strcpy ( ptr , "bad" ) ;
22: }