Is the following allowed by the standard?
#include <iostream>
extern int a;
auto a = 3;
int main(int, char**)
{
std::cout << a << std::endl;
return 0;
}
clang accepts the code. g++ complains for conflicting declaration.
Its not much clear to me from the standard, but then, there is this written
section 7.1.6.4 auto specifier
A program that uses auto in a context not explicitly allowed in this section is ill-formed.
Better read the mentioned section of the standard for all the allowed contexts.
Considering this, I believe g++ is correct and clang is wrong. But I could be wrong, there could be some separate section in standard which might be implying this context, but I could not find it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With