[Bug c++/79192] New: Angle bracket following typename is treated as template argument delimiter even if the name is not a template name
ricilake at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jan 23 03:33:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79192
Bug ID: 79192
Summary: Angle bracket following typename is treated as
template argument delimiter even if the name is not a
template name
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ricilake at gmail dot com
Target Milestone: ---
Sample code:
#include <iostream>
struct v {};
int main() {
std::cout << __VERSION__ << '\n' << (new v < new v) << '\n';
}
(Or, more simply):
int main() { return new int < new int; }
Standard reference: §14.2 paragraph 3:
After name lookup finds that a name is a template-name or that an operator-
function-id or a literal-operator-id refers to a set of overloaded functions
any member of which is a function template, if this is followed by a <, the <
is always taken as the delimiter of a template-argument-list and never as the
less-than operator.
In this case, however, the name is *not* a template-name, so I believe that the
< should be the less-than operator. Clang also believes this.
Initially ventilated on StackOverflow
http://stackoverflow.com/q/41786026/1566221 where the consensus appears to be
that it's a bug.
As mentioned in the SO post, I also tried it with function names ("&f < &f"),
and in that case GCC does distinguish between template names and non-template
names, so the behaviour of "new v < new v" seems doubly inconsistent.
More information about the Gcc-bugs
mailing list