All,
the following example does not the expected result with PGI 19.4 (LLVM or not does not matter):
#include <array>
#include <iostream>
enum MyEnum
#ifndef WORKS
: std::uint8_t
#endif
{
E_NULL,
E_ONE,
E_TWO
};
std::ostream & operator<<(
std::ostream & os,
const std::array<MyEnum, 3> & v)
{
for (auto d = 0; d < 3; ++d) {
os << v[d] << ((d < 2) ? ", " : "");
}
return os;
}
std::array<MyEnum, 3> v({ E_TWO, E_ONE, E_TWO });
const std::array<MyEnum, 3> v_const({ E_TWO, E_ONE, E_TWO });
constexpr std::array<MyEnum, 3> v_constexpr({ E_TWO, E_ONE, E_TWO });
int main()
{
std::cerr << "none: " << v[0] << ", " << v[1] << ", " << v[2] << "\n";
std::cerr << "none: " << v << "\n";
std::cerr << "const: " << v_const[0] << ", " << v_const[1] << ", " << v_const[2] << "\n";
std::cerr << "const: " << v_const << "\n";
std::cerr << "constexpr: " << v_constexpr[0] << ", " << v_constexpr[1] << ", " << v_constexpr[2] << "\n";
std::cerr << "constexpr: " << v_constexpr << "\n";
return 0;
}
It gives me:
none: 2, 0, 0
none: 2, 0, 0
const: 2, 1, 2
const: 2, 0, 0
constexpr: 2, 1, 2
constexpr: 2, 0, 0
Which indicates, that it is stored as an int, rather than an uint8_t, and thus prints 0. Compiling with -DWORKS works.
Best,