Trying with --clang wasn't easy. Other than with cppcheck alone, the code actually needs to compile with clang to do the check.
So I fixed all the includes just to see that some of my libraries (which, just as my main code, target gcc) fail with clang.
So I tried to fix the clang compiler issues with my code and generated a minmal, dependency-free example. I fixed all the issues and got code that compiled in both gcc and clang. Clang could also produce the ast-dump of the file.
Now testing the same with cppcheck (version 2.1) and the --clang option, gives me just a segmentation fault.
hmm.. I do not get a segmentation fault. But I don't get a dump file neither. With --debug I get debug output that looks ok. Here is the debug output for main:
Ronny.. can you please run this command: clang -cc1 -ast-dump test.cpp save the output in a file.. and then can you try to share that file with me somehow.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks! I will look at that file.
How did you compile Cppcheck? Maybe this is related with https://trac.cppcheck.net/ticket/9820 ... apparently there can be crashes if you compile with optimisations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The container is based on unbuntu:20:04 with clang and clang-tools installed via apt.
I can try with -O0 instead.
I just noticed that additionally to the self-compiled version, I also have a line about installing cppcheck via apt in there. I'll remove that too and see if it makes a difference. But cppcheck --version showed 2.2 dev, so I'm pretty sure the self-compiled version is used.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Trying with --clang wasn't easy. Other than with cppcheck alone, the code actually needs to compile with clang to do the check.
So I fixed all the includes just to see that some of my libraries (which, just as my main code, target gcc) fail with clang.
So I tried to fix the clang compiler issues with my code and generated a minmal, dependency-free example. I fixed all the issues and got code that compiled in both gcc and clang. Clang could also produce the ast-dump of the file.
Now testing the same with cppcheck (version 2.1) and the --clang option, gives me just a segmentation fault.
Here is the code of my example:
hmm.. I do not get a segmentation fault. But I don't get a dump file neither. With --debug I get debug output that looks ok. Here is the debug output for main:
Ronny.. can you please run this command:
clang -cc1 -ast-dump test.cpp
save the output in a file.. and then can you try to share that file with me somehow.I see the
?CXXFunctionalCastExpr?
now in the debug output .. that is something that probably should be fixed.After 1f8896e51c45356b7bbd1c47c0ee9671ff3e6d65 , I get a dump. So I can't reproduce any bad behavior as far as I see right now. :-(
If you still get the segfault.. I hope the
clang -cc1 -ast-dump test.cpp
output will help me reproduce it.Last edit: Daniel Marjamäki 2020-09-01
I've checked with a cppcheck build of todays main branch.
cppcheck --version just says Cppcheck 2.2 dev
clang version 10.0.0-4ubuntu1
I'm still getting the segmentation fault.
The output of
clang -cc1 -ast-dump simple.cpp
you can find here: https://hastebin.com/tomalocaki.rbThanks! I will look at that file.
How did you compile Cppcheck? Maybe this is related with https://trac.cppcheck.net/ticket/9820 ... apparently there can be crashes if you compile with optimisations.
I build cppcheck in a docker container with these commands:
The container is based on unbuntu:20:04 with clang and clang-tools installed via apt.
I can try with
-O0
instead.I just noticed that additionally to the self-compiled version, I also have a line about installing cppcheck via apt in there. I'll remove that too and see if it makes a difference. But
cppcheck --version
showed2.2 dev
, so I'm pretty sure the self-compiled version is used.I've checked wit
-O0
and indeed there is no longer a segmentation fault.Unfortunatley, there is also no output with
--dump
.