When I check this in C++ on Windows, I get a weird error message:
#include <atlstr.h> int _tmain(int argc, _TCHAR* argv[]) { CString foo; memset((void*)LPCTSTR(foo), 0, foo.GetLength()); return 0; }
cppcheck.exe" --library=windows --platform=win32A --language=c++ cppcheck-ast.c Checking cppcheck-ast.c ... cppcheck-ast.c:7:36: error: Syntax Error: AST broken, 'foo' doesn't have a parent. [internalAstError] memset((void*)LPCTSTR(foo), 0, foo.GetLength()); ^
It only happens with exactly those parameters (library, platform and language). In the code, the error only occurs if "foo" is used twice in the parameter list. If either the pointer or the length are given without using "foo", no error occurs.
LPCTSTR gets replaced with const char*, which leads to invalid code in the example. Added this example to https://trac.cppcheck.net/ticket/11430
LPCTSTR
const char*
Log in to post a comment.
When I check this in C++ on Windows, I get a weird error message:
cppcheck.exe" --library=windows --platform=win32A --language=c++ cppcheck-ast.c
Checking cppcheck-ast.c ...
cppcheck-ast.c:7:36: error: Syntax Error: AST broken, 'foo' doesn't have a parent. [internalAstError]
memset((void*)LPCTSTR(foo), 0, foo.GetLength());
^
It only happens with exactly those parameters (library, platform and language).
In the code, the error only occurs if "foo" is used twice in the parameter list. If either the pointer or the length are given without using "foo", no error occurs.
LPCTSTR
gets replaced withconst char*
, which leads to invalid code in the example.Added this example to https://trac.cppcheck.net/ticket/11430
Last edit: CHR 2024-09-07