Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A3-9-1 exception for using "unsigned char" for storage?
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:

alignas(T) unsigned char data[sizeof(T)];
T* p = new (data) T();
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.
Posted by and on behalf of
the MISRA C++ Working Group
Thank you for the quick response!

Forum Jump:

Users browsing this thread: 1 Guest(s)