-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
csmith meets cppcheck, the static analyser #134
Comments
Perhaps more interestingly, a possible bug: trunk/src/Expression.cpp:319:13: warning: Member variable 'Expression::expr_id' is not initialized in the copy constructor. [uninitMemberVar] Source code is Expression::Expression(eTermType e) : Expression::Expression(const Expression &expr) : } |
This does look like a bug! Thank you for reporting it! |
cppcheck also found some unused variables. Here is a git diff diff --git a/src/DefaultOutputMgr.cpp b/src/DefaultOutputMgr.cpp
diff --git a/src/FunctionInvocation.cpp b/src/FunctionInvocation.cpp
diff --git a/src/Probabilities.cpp b/src/Probabilities.cpp
diff --git a/src/StatementAssign.cpp b/src/StatementAssign.cpp
diff --git a/src/StatementFor.cpp b/src/StatementFor.cpp
cppcheck might run a bit faster with these deletions. |
cppcheck is a static analyser for C and C++ code.
Here is an example of some of its output:
trunk/src/StringUtils.cpp:115:40: performance: Function parameter 'str' should be passed by const reference. [passedByValue]
trunk/src/StringUtils.cpp:134:40: performance: Function parameter 'str' should be passed by const reference. [passedByValue]
trunk/src/StringUtils.cpp:153:44: performance: Function parameter 'str' should be passed by const reference. [passedByValue]
trunk/src/StringUtils.h:64:40: performance: Function parameter 'str' should be passed by const reference. [passedByValue]
trunk/src/StringUtils.h:66:40: performance: Function parameter 'str' should be passed by const reference. [passedByValue]
trunk/src/StringUtils.h:68:44: performance: Function parameter 'str' should be passed by const reference. [passedByValue]
And here is a diff for those performance problems:
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 201c493..8ef06f7 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -112,7 +112,7 @@ StringUtils::find_any_char(const string &s, size_t pos, const string& to_match)
}
void
-StringUtils::split_string(const string str, vector &v, const char sep_char)
+StringUtils::split_string(const string & str, vector &v, const char sep_char)
{
size_t pos = 0;
size_t start_pos = 0;
@@ -131,7 +131,7 @@ StringUtils::split_string(const string str, vector &v, const char sep_ch
}
void
-StringUtils::split_string(const string str, vector &v, string sep_chars)
+StringUtils::split_string(const string & str, vector &v, string sep_chars)
{
size_t pos = 0;
size_t start_pos = 0;
@@ -150,7 +150,7 @@ StringUtils::split_string(const string str, vector &v, string sep_chars)
}
void
-StringUtils::split_int_string(const string str, vector &values, string sep_chars)
+StringUtils::split_int_string(const string & str, vector &values, string sep_chars)
{
size_t pos = 0;
size_t start_pos = 0;
diff --git a/src/StringUtils.h b/src/StringUtils.h
index 66563a7..763d25c 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -61,11 +61,11 @@ public:
The text was updated successfully, but these errors were encountered: