@Abbas
I found this quite interesting topic because in our project we currently have a similar issue with C++20 vs. C++17.
The SQ scan detects a code smell (cpp:S3630) which can be solved by a C++20 feature only (std::bit_cast instead of reinterpret_cast).
But our compiler only supports C++17 which is set in the CMake file as compiler parameter:
We are using SonarQube LTS Version 8.9.7 (build 52159) which has bundled CFamily v6.20 which should detect the correct C++ standard if I understood the previous comments right?
07:29:55.148 DEBUG: * C++ (Community) 2.0.7.3119 (cxx)
07:29:55.148 DEBUG: * CFamily Code Quality and Security 6.20.3.42796 (cpp)
I moved you to another thread because I don’t think the two issues are related.
We are using SonarQube LTS Version 8.9.7 (build 52159) which has bundled CFamily v6.20 which should detect the correct C++ standard if I understood the previous comments right?
True and we should detect C++17 and not raise the issue with the since-c++20 tag. You can filter by tag on SonarQube to see the list of rules per C++standard or on rules.sonarsource,com.
You will notice that S3630 is not one of them. S3630 is a cppcoreguidline rule that says ““reinterpret_cast” should not be used”. Independently of the standard.
Now the rule message is standard dependent. if you are using C++20 and the cast can be replaced by bit_cast the rule message will be: “Replace “reinterpret_cast” with a “std::bit_cast”.”
But if you are not using C++20 or the cast is not equivalent to bit_cast, the rule message will be:
“Replace “reinterpret_cast” with a safer cast.”.
If I’m not wrong, you are getting the second message which is expected.
Hello @Abbas ,
Thank you for the quick response!
I obviously misinterpreted the verbose code smell explanation which mentioned a C++20 feature which might solve the issue. In future I will keep a closer look at the tags and also at the quite helpful list of rules per C++ standard. So I’m still learning to get more familiar with SonarQube and therefore appreciate the great support.