https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95657
Bug ID: 95657 Summary: Bogus error message in "auto" with -std=c++11 Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- This code bug.cc decltype (auto) foo( decltype (auto) a ){ } in GCC-trunk $g++ -c -std=c++11 bug.cc bug.cc:1:11: error: expected primary-expression before ‘auto’ 1 | decltype (auto) foo( decltype (auto) a ){ } | ^~~~ bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’ 1 | decltype (auto) foo( decltype (auto) a ){ } | ^~~~ bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’ bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’ bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’ bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’ bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’ bug.cc:1:33: error: expected primary-expression before ‘auto’ bug.cc:1:22: error: expected primary-expression before ‘decltype’ 1 | decltype (auto) foo( decltype (auto) a ){ } | ^~~~~~~~~~~~~~~~ I am sure there were some duplicate error messages about "error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’". While in clang $clang++ -c -std=c++11 bug.cc bug.cc:1:11: warning: 'decltype(auto)' type specifier is a C++14 extension [-Wc++14-extensions] decltype (auto) foo( decltype (auto) a ){ } ^ bug.cc:1:33: warning: 'decltype(auto)' type specifier is a C++14 extension [-Wc++14-extensions] decltype (auto) foo( decltype (auto) a ){ } ^ bug.cc:1:22: error: 'decltype(auto)' not allowed in function prototype decltype (auto) foo( decltype (auto) a ){ } ^~~~~~~~ bug.cc:1:1: error: deduced return types are a C++14 extension decltype (auto) foo( decltype (auto) a ){ } ^ 2 warnings and 2 errors generated.