After running cppcheck v1.78 on our codebase, one file caused a seg-fault. The offending file was reduced to the following, and stll caused a seg-fault. Can't quickly try a newer version of cppcheck due to tightly-controlled environment.
test101.H:
class AlertSvc: public AlertService
{
std::set<alerthelper_i*> alert_helpers;
typedef struct
{
M_Struct alert_data;
short previous;
short next;
} AlertRecoveryDB;
};</alerthelper_i*>
If you indent the source code by 4 spaces it does not get altered (you can also use three tilde or backticks around the code, see https://sourceforge.net/p/cppcheck/discussion/markdown_syntax).
I have copied and repaired the code how i think it was meant to be and i can not reproduce the segfault with Cppcheck 1.88 dev.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After running cppcheck v1.78 on our codebase, one file caused a seg-fault. The offending file was reduced to the following, and stll caused a seg-fault. Can't quickly try a newer version of cppcheck due to tightly-controlled environment.
test101.H:
class AlertSvc: public AlertService
{
std::set<alerthelper_i*> alert_helpers;
typedef struct
{
M_Struct alert_data;
short previous;
short next;
} AlertRecoveryDB;
};</alerthelper_i*>
test101.C:
include "test101.H"
void AlertSvc::ClearEntry()
{
memset(&alert_recovery_database[0], 0, sizeof(AlertRecoveryDB));
}
void AlertSvc::packAlertData(M_Struct *alert_msg)
{
for(auto helper : alert_helpers)
do_stuff();
}
If you indent the source code by 4 spaces it does not get altered (you can also use three tilde or backticks around the code, see https://sourceforge.net/p/cppcheck/discussion/markdown_syntax).
I have copied and repaired the code how i think it was meant to be and i can not reproduce the segfault with Cppcheck 1.88 dev.
Forgot to mention, running Linux command-line version.
Can you try this:
No installation is required.
1.79 and later don't crash on this code.
That sounds good to me.