A3-9-1 exception for using "unsigned char" for storage? - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: AUTOSAR C++:2014 rules (https://forum.misra.org.uk/forumdisplay.php?fid=185) +--- Thread: A3-9-1 exception for using "unsigned char" for storage? (/showthread.php?tid=1662) |
A3-9-1 exception for using "unsigned char" for storage? - cgpzs - 30-10-2023 A3-9-1 forbids the use of char (and a recent question clarifies that it's intended for signed/unsigned char). However, how can we create storage in that case, since we don't have std::byte until C++17? We could use `std::uint8_t`, but that's not the type that is used in the Standard, and could potentially not be identical to "unsigned char" depending on platform. Example use case: Code: alignas(T) unsigned char data[sizeof(T)]; RE: A3-9-1 exception for using "unsigned char" for storage? - misra cpp - 06-11-2023 We agree that unsigned char is the correct type to use in this situation (in the absence of std::byte). This is will reviewed in a future version of the standard. RE: A3-9-1 exception for using "unsigned char" for storage? - cgpzs - 09-11-2023 Thank you for the quick response! |