I was expecting to see failures when using c++11 features such as auto/nullptr etc and building with flag std-c++03. However cppcheck doesn't complain. Is this expected behavior?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Chapter 1. Introduction
Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools, it doesn't detect syntax errors. Instead, Cppcheck detects the types of bugs that the compilers normally fail to detect. The goal is no false positives.
This does not mean that Cppcheck accepts all garbage :) There is a syntaxError message that is issued when Cppcheck really can not go on analyzing the source code because it really looks invalid to Cppcheck and does not make sense at all.
I am not sure what happens when you set the standard to C++03 for Cppcheck analysis but use nullptr. Maybe Cppcheck just handles nullptr correctly as if this part of the source code is C++11 code.
Generally the source code should be compilable and the more information you give to Cppcheck (defines, libraries, project include directories, ...) the better should be the result.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was expecting to see failures when using c++11 features such as
auto/nullptr
etc and building with flagstd-c++03
. However cppcheck doesn't complain. Is this expected behavior?This is expected behaviour. Cppcheck is not a syntax validator.
Oh ok so it expects that the code is valid. I would have thought if it didn't understand the syntax it would throw up some sort of error though.
From the Cppcheck manual:
This does not mean that Cppcheck accepts all garbage :) There is a
syntaxError
message that is issued when Cppcheck really can not go on analyzing the source code because it really looks invalid to Cppcheck and does not make sense at all.I am not sure what happens when you set the standard to C++03 for Cppcheck analysis but use
nullptr
. Maybe Cppcheck just handlesnullptr
correctly as if this part of the source code is C++11 code.Generally the source code should be compilable and the more information you give to Cppcheck (defines, libraries, project include directories, ...) the better should be the result.