If ( ( x = static_cast(1) ) & y) // not compliant Such a cast is completely superfluous as the operand will get immediately integer promoted back to int anyway. The important part to understand is how implicit promotions work and how to avoid them:Ĭasting the 1 literal to unsigned short will not solve anything. Compliance against MISRA-C++ can obviously not be checked with a MISRA-C checker.Īnyway, assuming you have a system with 32 bit integers, this should solve the problem no matter MISRA version: if ( ( static_cast(x) = 1u ) & y) // compliant You should be using MISRA-C++ when writing C++ code, everything else will be a violation of the MISRA rules. ![]() It is not clear which version of MISRA you are using.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |