gcc 8 and clang 7 do not accept the following code, which should default-construct a temporary of type unsigned int
:
unsigned int ui = unsigned int{};
clang 7 reports an error such as
<source>:6:22: error: expected primary-expression before 'unsigned'
Visual C++ 2015 and 2017 accept this.
Obviously, this works with a type such as int
, or any default-constructible class type.
Is this correct C++14 code (and in that case a bug of clang and gcc)? If not, why not? Which types other than unsigned types would suffer from the same restriction?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…