mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Add __may_alias__ attribute to gsl::byte (#668)
C++17 defines `std::byte*` to have the same aliasing properties as `char*`. Hence, we mark it with the `__may_alias__` attribute under gcc and clang. Based on the fix by Martin Moene in byte-lite. Fixes #663
This commit is contained in:
parent
c4c1f6395a
commit
d6b26b367b
@ -57,6 +57,13 @@
|
|||||||
|
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
// Use __may_alias__ attribute on gcc and clang
|
||||||
|
#if defined __clang__ || (__GNUC__ > 5)
|
||||||
|
#define byte_may_alias __attribute__((__may_alias__))
|
||||||
|
#else // defined __clang__ || defined __GNUC__
|
||||||
|
#define byte_may_alias
|
||||||
|
#endif // defined __clang__ || defined __GNUC__
|
||||||
|
|
||||||
namespace gsl
|
namespace gsl
|
||||||
{
|
{
|
||||||
#if GSL_USE_STD_BYTE
|
#if GSL_USE_STD_BYTE
|
||||||
@ -69,7 +76,7 @@ using std::to_integer;
|
|||||||
|
|
||||||
// This is a simple definition for now that allows
|
// This is a simple definition for now that allows
|
||||||
// use of byte within span<> to be standards-compliant
|
// use of byte within span<> to be standards-compliant
|
||||||
enum class byte : unsigned char
|
enum class byte_may_alias byte : unsigned char
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user