Skip to content
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

Fix MISRA C++ 2023 rule 8.2.5 "reinterpret_cast shall not be used" #586

Closed
mohammedRafeeque opened this issue Apr 9, 2024 · 4 comments
Closed
Assignees
Labels
bug Something isn't working c++ C++ language generator
Milestone

Comments

@mohammedRafeeque
Copy link

mohammedRafeeque commented Apr 9, 2024

Zserio version and language
Zserio: latest from master
Language: C++

Describe the bug
Check and resolve SCA warning MISRACPP2023-8_2_5-a ("reinterpret_cast shall not be used") reported in Zserio on C++ runtime library.

Rule ID severity Message Path Line Link to sonarcloud
MISRACPP2023-8_2_5-a 2 reinterpret_cast' should not be used /zserio_runtime/src/roadgraph_reliable/zserio_runtime/zserio/FileUtil.cpp 17 https://sonarcloud.io/project/issues?open=AY3k4v8yXMcagTJBbG3h&id=ndsev_zserio
MISRACPP2023-8_2_5-a 2 reinterpret_cast' should not be used /zserio_runtime/src/roadgraph_reliable/zserio_runtime/zserio/FileUtil.cpp 42 https://sonarcloud.io/project/issues?open=AY3k4v8yXMcagTJBbG3j&id=ndsev_zserio
MISRACPP2023-8_2_5-a 2 'reinterpret_cast' should not be used /zserio_runtime/src/roadgraph_reliable/zserio_runtime/zserio/FloatUtil.cpp 164 https://sonarcloud.io/project/issues?open=AY3k4v9QXMcagTJBbG4N&id=ndsev_zserio
MISRACPP2023-8_2_5-a 2 reinterpret_cast' should not be used /zserio_runtime/src/roadgraph_reliable/zserio_runtime/zserio/FloatUtil.cpp 171 https://sonarcloud.io/project/issues?open=AY3k4v9QXMcagTJBbG4P&id=ndsev_zserio
MISRACPP2023-8_2_5-a 2 reinterpret_cast' should not be used /zserio_runtime/src/roadgraph_reliable/zserio_runtime/zserio/FloatUtil.cpp 178 https://sonarcloud.io/project/issues?open=AY3k4v9QXMcagTJBbG4R&id=ndsev_zserio
MISRACPP2023-8_2_5-a 2 reinterpret_cast' should not be used /zserio_runtime/src/roadgraph_reliable/zserio_runtime/zserio/FloatUtil.cpp 185 https://sonarcloud.io/project/issues?open=AY3k4v9QXMcagTJBbG4T&id=ndsev_zserio

How to reproduce
see the sonarcloud links

Expected behavior
No SCA warnings for MISRA 2023 ruleset

Additional context

@mohammedRafeeque mohammedRafeeque added the bug Something isn't working label Apr 9, 2024
@mohammedRafeeque
Copy link
Author

@mikir @Roland-Homeier FYI:

@CheisonShweta
Copy link

Adding to the above list there are 2 more occurrences for MISRACPP2023-15_1_3-a.

<style> </style>
Rule ID Severity Message Path Line Link to sonarcloud  
MISRACPP2023-15_1_3-a 2 Constructor 'UniquePtrDeleter' allowing conversion should be made explicit /zserio_runtime/include/roadgraph_reliable/zserio_runtime/zserio/UniquePtr.h 57 https://sonarcloud.io/project/issues?open=AY3k4v99XMcagTJBbG5C&id=ndsev_zserio
MISRACPP2023-15_1_3-a 2 Constructor 'UniquePtrDeleter' allowing conversion should be made explicit /zserio_runtime/include/roadgraph_reliable/zserio_runtime/zserio/UniquePtr.h 68 https://sonarcloud.io/project/issues?open=AY3k4v99XMcagTJBbG5D&id=ndsev_zserio

@mikir
Copy link
Contributor

mikir commented Apr 12, 2024

Adding to the above list there are 2 more occurrences for MISRACPP2023-15_1_3-a.

This will be fix within scope of #593.

@mikir mikir changed the title Fix for SCA warnings reported MISRA 2023 rules MISRACPP2023-8_2_5-a and MISRACPP2023-15_1_3-a in sonarcloud SCA run Fix MISRA C++ 2023 rule 8.2.5 "reinterpret_cast shall not be used" Apr 12, 2024
@mikir mikir added the c++ C++ language generator label Apr 12, 2024
@mikir mikir self-assigned this Apr 18, 2024
@mikir
Copy link
Contributor

mikir commented Apr 23, 2024

We have got rid of reinterpret_cast wherever it was possible.

However, the following 8 SonarCloud issues in the C++ runtime library have been accepted as the exceptions:

Module Line Command Link
AnyHolder.h 821 reinterpret_cast<detail::NonHeapHolder<T, ALLOC>*>( &m_untypedHolder.inPlace); SonarCloud
AnyHolder.h 827 reinterpret_cast<const detail::NonHeapHolder<T, ALLOC>*>( &m_untypedHolder.inPlace); SonarCloud
AnyHolder.h 857 reinterpret_cast<detail::IHolder<ALLOC>*>( &m_untypedHolder.inPlace) SonarCloud
AnyHolder.h 864 reinterpret_cast<const detail::IHolder<ALLOC>*>( &m_untypedHolder.inPlace) SonarCloud
FileUtil.cpp 17 reinterpret_cast<const char*>(buffer) SonarCloud
FileUtil.cpp 42 reinterpret_cast<char*>(bitBuffer.getBuffer() SonarCloud
OptionalHolder.h 628 reinterpret_cast<T*>(&m_inPlace); SonarCloud
OptionalHolder.h 638 reinterpret_cast<const T*>(&m_inPlace); SonarCloud

We are not aware of any reinterpret_cast in the generated code.

@mikir mikir closed this as completed Apr 26, 2024
@Mi-La Mi-La reopened this Aug 2, 2024
Mi-La added a commit that referenced this issue Aug 2, 2024
Mi-La added a commit that referenced this issue Aug 5, 2024
@mikir mikir modified the milestones: 2.14, 2.15 Aug 6, 2024
Mi-La added a commit that referenced this issue Aug 8, 2024
@Mi-La Mi-La self-assigned this Aug 8, 2024
@Mi-La Mi-La closed this as completed Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c++ C++ language generator
Projects
None yet
Development

No branches or pull requests

4 participants