This code compiles with MSVC, but not with GCC or Clang.
auto a = int{};
auto ua = unsigned int {};
I strongly suspect it might be legit C , but that the mix between the ancient "C style / types with spaces" and the 50 differents ways of doing initialization in C make this a very hard job for compilers.
CodePudding user response:
According to the C 20 Standard (7.6.1.4 Explicit type conversion (functional notation)):
1 A simple-type-specifier (9.2.9.3) or typename-specifier (13.8) followed by a parenthesized optional expression-list or by a braced-init-list (the initializer) constructs a value of the specified type given the initializer. If the type is a placeholder for a deduced class type, it is replaced by the return type of the function selected by overload resolution for class template deduction (12.4.2.9) for the remainder of this subclause.
So you need to write
auto ua = unsigned {};