I have two different partial explicit class template specializations that results in an ODR violation by cppcheck which I believe to be a false positive. I could be wrong. Regardless, I am having this error present on a recent build from master branch. Here is a sample case that replicates this error:
PrimaryTemplate.hpp
template<typename T1, typename T2>
struct Test
{};
Sorry for the strange nature of the code, I tried to replicate the code that was producing the ODR violation in my project into a simple case and whittled out the unnecessary details.
In my project, the struct which I based Test off of is not a common base class. Rather, there is a macro defined in my project which takes in a single type and creates specializations of that struct. Each use of the macro creates a ctuOneDefinitionRuleViolation on cppcheck.
Last edit: Muhammad Javed 2022-12-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The only argument I pass to cppcheck is the directory containing those 3 files I posted above. I even double checked to make sure I was running the cppcheck that I built yesterday (2.10 dev).
After double checking to make sure that the code is the same as in the one I provided, I ran cppcheck again and I have attached the results:
I have two different partial explicit class template specializations that results in an ODR violation by cppcheck which I believe to be a false positive. I could be wrong. Regardless, I am having this error present on a recent build from master branch. Here is a sample case that replicates this error:
PrimaryTemplate.hpp
A.cpp
B.cpp
This does not look like an ODR violation to me. However, if it is then I am very sorry for wasting anybody's time. Thanks!
the code looks strange. is
Test
supposed to be a common base class?Sorry for the strange nature of the code, I tried to replicate the code that was producing the ODR violation in my project into a simple case and whittled out the unnecessary details.
In my project, the struct which I based
Test
off of is not a common base class. Rather, there is a macro defined in my project which takes in a single type and creates specializations of that struct. Each use of the macro creates actuOneDefinitionRuleViolation
on cppcheck.Last edit: Muhammad Javed 2022-12-14
How do you call cppcheck? I'm failing to reproduce this so far.
The only argument I pass to cppcheck is the directory containing those 3 files I posted above. I even double checked to make sure I was running the cppcheck that I built yesterday (2.10 dev).
After double checking to make sure that the code is the same as in the one I provided, I ran cppcheck again and I have attached the results:
I had run cppcheck on a single file, not on the directory before.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11435
Thank you so much!