Consider the following program (prog.cc): auto i = 0, f(); int main() {} Compile it with the following command line: g++ prog.cc -std=c++14 -pedantic-errors No error messages are given. I expect to get at least one error message since the program is ill-formed. The program is ill-formed by [decl.spec.auto]/8: http://eel.is/c++draft/dcl.dcl#dcl.spec.auto-8 "If the init-declarator-list contains more than one init-declarator, they shall all form declarations of variables." I have tried this with gcc HEAD 6.0.0 20150725 here: http://melpon.org/wandbox/permlink/UaCnMgfMlG9nDqf3
EDG and Clang also accept this in C++14 mode (and like GCC, reject it in C++11 mode).
(In reply to Jonathan Wakely from comment #1) > EDG and Clang also accept this in C++14 mode (and like GCC, reject it in > C++11 mode). I think that is because type deduction for return types of functions was introduced in c++14. The following program is well-formed in c++14, but not in c++11: auto f(); int main() {}
(In reply to Jonathan Wakely from comment #1) > EDG and Clang also accept this in C++14 mode (and like GCC, reject it in > C++11 mode). (In reply to Anders Granlund from comment #2) > (In reply to Jonathan Wakely from comment #1) > > EDG and Clang also accept this in C++14 mode (and like GCC, reject it in > > C++11 mode). > > I think that is because type deduction for return types of functions was > introduced in c++14. > > The following program is well-formed in c++14, but not in c++11: > > auto f(); > int main() {} (In reply to Jonathan Wakely from comment #1) > EDG and Clang also accept this in C++14 mode (and like GCC, reject it in > C++11 mode). It is interesting that the compilers seem to agree, looks like they all have this bug. I noticed an interesting thing however. Consider this program: auto i = 0, f(); auto f() { return false; } int main() {} Clang accepts it, but GCC rejects it (I didn't try EDG).
(In reply to Anders Granlund from comment #3) > > I think that is because type deduction for return types of functions was > > introduced in c++14. Yes, I understand why they reject it in C++11 mode, my point was that they all consistently accept it in C++14 mode. > I noticed an interesting thing however. Consider this program: > > auto i = 0, f(); > auto f() { return false; } > int main() {} > > Clang accepts it, but GCC rejects it (I didn't try EDG). EDG accepts that too.
(In reply to Jonathan Wakely from comment #4) > (In reply to Anders Granlund from comment #3) > > > I think that is because type deduction for return types of functions was > > > introduced in c++14. > > Yes, I understand why they reject it in C++11 mode, my point was that they > all consistently accept it in C++14 mode. > > > I noticed an interesting thing however. Consider this program: > > > > auto i = 0, f(); > > auto f() { return false; } > > int main() {} > > > > Clang accepts it, but GCC rejects it (I didn't try EDG). > > EDG accepts that too. Yes, it is interesting that three different compilers seems to disagree with my interpretation of the c++ standard. I still think this is a bug. I'm trying to get a second option about this interpretation of the c++ standard here: https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/_xOC2ou49ZQ
Now I got the reply. It seems like the wording of the standard changed with the resolution of this c++ standard core defect: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1265 So the problem is that GCC hasn't implemented this yet.
Resolved in r244071.