Why does auto a=1; compile in C?

auto is an old C keyword that means “local scope”. auto a is the same as auto int a, and because local scope is the default for a variable declared inside a function, it’s also the same as int a in this example. This keyword is actually a leftover from C’s predecessor B, where there … Read more

‘auto’ as a template argument placeholder for a function parameter

This syntax is valid in the C++ Concepts Technical Specification, but not in C++20. In C++20 concepts, auto is only permitted at the top level in a function parameter type. The relevant rule is [dcl.spec.auto] paragraph 2: A placeholder-type-specifier of the form type-constraint[opt] auto can be used as a decl-specifier of the decl-specifier-seq of a … Read more