Here is the minimal example:
#include <array>
template <class... T>
constexpr std::array<unsigned char, sizeof...(T)> act(T... aArgs)
{
return std::array<unsigned char, sizeof...(T)>{aArgs...};
}
int main()
{
act(5, 5);
}
EDIT Where GCC and Clang can compile that snippet without a complaint No they cannot.
The latest MSVC fails with:
<source>(6): error C2397: conversion from 'int' to '_Ty' requires a narrowing conversion
with
[
_Ty=unsigned char
]
See: https://godbolt.org/z/1PmeLk
- Since in this situation, the compiler has everything it needs to statically verify that the call to
act(5, 5)does not overflow for the provided values, is it a standard-compliant behaviour to fail on this code?
Bonus question:
- Since there is no literal suffix to get an unsigned char literal, how to workaround this bug
||fix this non-standard code?