Summary: | [DR1265] Mixing init-declarator for variables and functions in declaration with auto type-specifier | ||
---|---|---|---|
Product: | gcc | Reporter: | Anders Granlund <anders.granlund.0> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | webrown.cpp |
Priority: | P3 | Keywords: | accepts-invalid |
Version: | unknown | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2015-07-26 00:00:00 |
Description
Anders Granlund
2015-07-26 13:54:18 UTC
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. |