{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/GSL/issues/130","labels_url":"https://api.github.com/repos/Microsoft/GSL/issues/130/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/GSL/issues/130/comments","events_url":"https://api.github.com/repos/Microsoft/GSL/issues/130/events","html_url":"https://github.com/Microsoft/GSL/issues/130","id":109928047,"number":130,"title":"Problems with byte definition","user":{"login":"rkawulak","id":3124553,"avatar_url":"https://avatars.githubusercontent.com/u/3124553?v=3","gravatar_id":"","url":"https://api.github.com/users/rkawulak","html_url":"https://github.com/rkawulak","followers_url":"https://api.github.com/users/rkawulak/followers","following_url":"https://api.github.com/users/rkawulak/following{/other_user}","gists_url":"https://api.github.com/users/rkawulak/gists{/gist_id}","starred_url":"https://api.github.com/users/rkawulak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkawulak/subscriptions","organizations_url":"https://api.github.com/users/rkawulak/orgs","repos_url":"https://api.github.com/users/rkawulak/repos","events_url":"https://api.github.com/users/rkawulak/events{/privacy}","received_events_url":"https://api.github.com/users/rkawulak/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-06T03:17:49Z","updated_at":"2015-10-06T07:18:01Z","closed_at":"2015-10-06T07:18:01Z","body":"There are two problems with the following definition in `array_view.h`:\r\n\r\n    enum class byte : std::uint8_t {};\r\n\r\nFirst, `uint8_t` is not the same thing as byte, and moreover – according to the Standard – [it is optional](http://en.cppreference.com/w/cpp/types/integer#Types) and may be missing on platforms not supporting 8-bit integers.\r\n\r\nSecond, according to the [strict aliasing rule](http://en.cppreference.com/w/cpp/language/reinterpret_cast#Type_aliasing), only pointers to `char` and `unsigned char` may refer to object representation – otherwise the behaviour is undefined.\r\n\r\nTherefore the only way `byte` can be defined in a practical, standard-conforming and portable way is:\r\n\r\n    using byte = unsigned char;\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/GSL/issues/comments/145765777","html_url":"https://github.com/Microsoft/GSL/issues/130#issuecomment-145765777","issue_url":"https://api.github.com/repos/Microsoft/GSL/issues/130","id":145765777,"user":{"login":"gdr-at-ms","id":11031650,"avatar_url":"https://avatars.githubusercontent.com/u/11031650?v=3","gravatar_id":"","url":"https://api.github.com/users/gdr-at-ms","html_url":"https://github.com/gdr-at-ms","followers_url":"https://api.github.com/users/gdr-at-ms/followers","following_url":"https://api.github.com/users/gdr-at-ms/following{/other_user}","gists_url":"https://api.github.com/users/gdr-at-ms/gists{/gist_id}","starred_url":"https://api.github.com/users/gdr-at-ms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdr-at-ms/subscriptions","organizations_url":"https://api.github.com/users/gdr-at-ms/orgs","repos_url":"https://api.github.com/users/gdr-at-ms/repos","events_url":"https://api.github.com/users/gdr-at-ms/events{/privacy}","received_events_url":"https://api.github.com/users/gdr-at-ms/received_events","type":"User","site_admin":false},"created_at":"2015-10-06T07:18:01Z","updated_at":"2015-10-06T07:18:01Z","body":"We require that target platform supports `uint8_t`, just the way we require the target platform to support `<algorithm>` which is optional on freestanding implementations.  \r\nFurthermore, we require that the implementation aliases `std::uint8_t` to `unsigned char`.  We could update the documentation to state that if that would create less confusion for people.\r\n\r\nThe second point about 3.10/10 from the standards text, but we view it as a defect in the standards in the sense that that paragraph wasn't updated when scoped enumerations were introduced.  We will raise that point with the committee.\r\n\r\nWe do want to have a distinct type for 'byte'.  Using a class that contains a simple byte, when a scope enumeration could do, would introduce an abstraction penalty on platforms with ABIs that still fail to support C++ efficiently."}}