[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Jonathan Wakely changed: What|Removed |Added Last reconfirmed|2016-01-22 00:00:00 |2016-2-8 --- Comment #32 from Jonathan Wakely --- The new testcase gets two errors (both due to treating "q->exp< N" as the start of a template) and Manu's suggestion in comment 30 only helps with the second one. Slightly further reduced (the macro shows how in gcc-5 this bug was only encountered by using and using std::exp, but in gcc 6 it's also encountered with because that now has the using declaration): namespace std { template T exp(T t) { return t; } } #ifndef NO_USING using std::exp; #endif template class A { struct B { long exp; }; void m_fn1(); }; template void A::m_fn1() { long insert_exp = 1; B q; (q->exp < insert_exp); } exp.cc: In member function ‘void A< >::m_fn1()’: exp.cc:16:13: error: the value of ‘insert_exp’ is not usable in a constant expression (q->exp < insert_exp); ^ exp.cc:14:8: note: ‘long int insert_exp’ is not const long insert_exp = 1; ^ exp.cc:16:7: error: parse error in template argument list (q->exp < insert_exp); ^
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #31 from Marek Polacek --- Another testcase which we just stumbled upon: double exp(double); #ifndef HIDE_NEW_OVERLOAD template T exp(T t) { return ::exp((double)t); } #endif template class A { struct B { long exp; }; void m_fn1(); }; template void A::m_fn1() { long insert_exp = 1; B q; (q->exp < insert_exp); }
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 --- Comment #30 from Manuel López-Ibáñez --- (In reply to Jonathan Wakely from comment #28) > Another example: > > template inline void end(Tp) { } > > template bool tnegative(const T& t) { return t.end < 0; } > > > pe.cc: In function ‘bool tnegative(const T&)’: > pe.cc:3:61: error: parse error in template argument list > template bool tnegative(const T& t) { return t.end < 0; } > ^~~ /* ??? Can we actually assume that, if template_id == error_mark_node, we will have issued a diagnostic to the user, as opposed to simply marking the tentative parse as failed? */ if (cp_parser_error_occurred (parser) && template_id != error_mark_node) => error_at (token->location, "parse error in template argument list"); But actually the issue is that template_id != error_mark_node, but it is not a template id, so we are still tentatively parsing and this error is wrong.
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Jonathan Wakely changed: What|Removed |Added Last reconfirmed|2006-10-21 21:32:49 |2016-1-22 --- Comment #29 from Jonathan Wakely --- You can trick G++ into finishing the parse incorrectly: template inline void end(int) { } struct S { int end; }; template bool both_negative(const T& t, int u) { return t.end < 0 && 0 > (u); } int main() { return both_negative( S{-1}, -2 ); } pe.cc: In instantiation of ‘bool both_negative(const T&, int) [with T = S]’: pe.cc:10:35: required from here pe.cc:6:50: error: ‘end’ is not a member template function bool both_negative(const T& t, int u) { return t.end < 0 && 0 > (u); } ~~^~ I know it isn't, that's why I didn't write "t.template end<" :-)
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 --- Comment #28 from Jonathan Wakely --- Another example: template inline void end(Tp) { } template bool tnegative(const T& t) { return t.end < 0; } pe.cc: In function ‘bool tnegative(const T&)’: pe.cc:3:61: error: parse error in template argument list template bool tnegative(const T& t) { return t.end < 0; } ^~~
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Paolo Carlini changed: What|Removed |Added Status|ASSIGNED|NEW Assignee|paolo.carlini at oracle dot com|unassigned at gcc dot gnu.org --- Comment #27 from Paolo Carlini --- This should be fixed ASAP, but I'm not actively working on it at the moment.
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Colin MacKenzie changed: What|Removed |Added CC||colin.mackenzie at ineoquest dot c ||om --- Comment #26 from Colin MacKenzie --- Had this one today. Strange that it compiles fine in 4.4.6 but not in 4.8.2. error: parse error in template argument list Ex: assert(block.begin < block.end); works when I parenthesize the block.begin Ex. assert( (block.begin) < block.end);
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Paolo Carlini changed: What|Removed |Added CC||xyshh94225 at hotmail dot com --- Comment #25 from Paolo Carlini --- *** Bug 65878 has been marked as a duplicate of this bug. ***
[Bug c++/10200] Weird clash with same names in different scopes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Andrew Pinski changed: What|Removed |Added CC||tomalk at mathematik dot uni-freib ||urg.de --- Comment #24 from Andrew Pinski --- *** Bug 63414 has been marked as a duplicate of this bug. ***
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Paolo Carlini changed: What|Removed |Added Status|NEW |ASSIGNED CC|gcc-bugs at gcc dot gnu.org| Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com --- Comment #23 from Paolo Carlini --- Mine.
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Paolo Carlini changed: What|Removed |Added CC||walter.mascarenhas at gmail ||dot com --- Comment #22 from Paolo Carlini 2013-03-04 10:09:01 UTC --- *** Bug 56516 has been marked as a duplicate of this bug. ***
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Paolo Carlini changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #21 from Paolo Carlini 2012-08-23 10:14:16 UTC --- Jason, noticed this very, very old issue which however clang too fixed only this March. Wondered if you have tips, believe it would be easy to fix in our front-end too, what else...
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Matt Giuca changed: What|Removed |Added CC||eatmyshortz at gmail dot ||com --- Comment #20 from Matt Giuca 2012-05-30 00:05:47 UTC --- I think this is the same bug in Clang: http://llvm.org/bugs/show_bug.cgi?id=11856 It was fixed in March: http://llvm.org/viewvc/llvm-project?view=rev&revision=152520
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Andrew Pinski changed: What|Removed |Added CC||timon.gehr at gmx dot ch --- Comment #19 from Andrew Pinski 2011-12-23 18:56:42 UTC --- *** Bug 51664 has been marked as a duplicate of this bug. ***
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Manuel López-Ibáñez changed: What|Removed |Added Status|ASSIGNED|NEW CC||manu at gcc dot gnu.org --- Comment #18 from Manuel López-Ibáñez 2011-10-19 22:29:28 UTC --- This still happens in trunk (GCC 4.7 rev 180166).
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Wolfgang Bangerth changed: What|Removed |Added CC||bangerth at gmail dot com --- Comment #17 from Wolfgang Bangerth 2011-10-09 13:34:27 UTC --- Still happens with gcc 4.5.1.
[Bug c++/10200] Weird clash with same names in different scopes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200 Jay Foad changed: What|Removed |Added CC||jay.foad at gmail dot com --- Comment #16 from Jay Foad 2011-05-24 09:17:21 UTC --- > This is almost the same as the case discussed in DR 141. > > In particular, we must determine whether "node.foo <" is the start of a > template, or not. [basic.lookup.classref] says that we look in the class of > the > object expression, i.e., X::node. However, that's a dependent type. So, > we > don't actually try to lookup there. Thus, we then go on to do lookup in the > scope of the containing postfix-expression, which finds the global template > function. DR 141 suggests that we should not do the second lookup. However, > this DR is still in the "open" state; the committee has taken no action as of > yet. DR 141 was resolved in CD1: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#141 It seems like we should still do the second lookup.
[Bug c++/10200] Weird clash with same names in different scopes
--- Comment #15 from pinskia at gcc dot gnu dot org 2009-03-09 18:16 --- *** Bug 39407 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||jwakely dot gcc at gmail dot ||com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200
[Bug c++/10200] Weird clash with same names in different scopes
--- Comment #14 from pinskia at gcc dot gnu dot org 2008-09-20 02:56 --- *** Bug 20308 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||igodard at pacbell dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200
[Bug c++/10200] Weird clash with same names in different scopes
--- Comment #13 from pinskia at gcc dot gnu dot org 2007-06-19 23:10 --- *** Bug 32408 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||chsalvia at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200
[Bug c++/10200] Weird clash with same names in different scopes
--- Additional Comments From mmitchel at gcc dot gnu dot org 2005-04-05 06:03 --- This is almost the same as the case discussed in DR 141. In particular, we must determine whether "node.foo <" is the start of a template, or not. [basic.lookup.classref] says that we look in the class of the object expression, i.e., X::node. However, that's a dependent type. So, we don't actually try to lookup there. Thus, we then go on to do lookup in the scope of the containing postfix-expression, which finds the global template function. DR 141 suggests that we should not do the second lookup. However, this DR is still in the "open" state; the committee has taken no action as of yet. However, independently of that, [temp.names] says that when the object has a dependent type (as it does in this case), then the name is a template only if the template keyword is explicitly used. So, the compiler is definitely wrong in this case. -- What|Removed |Added AssignedTo|unassigned at gcc dot gnu |mark at codesourcery dot com |dot org | Status|NEW |ASSIGNED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200
[Bug c++/10200] Weird clash with same names in different scopes
--- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-10-13 14:50 --- It's parser bug. Not working on it anymore. -- What|Removed |Added AssignedTo|lerdsuwa at gcc dot gnu dot |unassigned at gcc dot gnu |org |dot org Status|ASSIGNED|NEW http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10200