[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #1 from pinskia at gcc dot gnu dot org 2008-05-10 23:01 --- This is not a bug: templateclass TC, int V int CxTC, V::fx(TC* tc) { return tc-fV(); } You frogot the template keyword. That is the above should be: templateclass TC, int V int CxTC, V::fx(TC* tc) { return tc-template fV(); } as tc is dependent, you need to tell the compiler that it will be a template, otherwise it will try to parse the as a that it is parsing it as (tc-f V) () . Also EDG in strict mode (non GNU extension mode) rejects it as expected. See also http://gcc.gnu.org/gcc-3.4/changes.html (You must now use the typename and template keywords to disambiguate dependent names, as required by the C++ standard. ) . -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #2 from starlight at binnacle dot cx 2008-05-10 23:41 --- This was more of a learning experience than a forgetting and remembering one. Thank you for the help. Several template behaviors required by a strict ISO standard reading are miles distant from intuition. This surely qualifies, especially as three major vendor compilers accept it without the keyword. An improved error message from GCC would help immensely. Spent several hours googling this and coming up dry (including a review of closed GCC bug reports) before reporting it. Can't afford to read ISO 14882 from start to finish every time this happens. Another example is the despicable exclusion of base template member names from the default scope. Regardless of any correctness, it's an nightmare to constantly insert 'this-' and/or 'using' constructs to overcome the behavior that 99.999% of the time serves no useful purpose. A command switch separate from -fpermissive should exist for relaxing this one insanely annoying rule. At least the error message here finally provides a meaningful indication regarding the cause of the problem. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #3 from starlight at binnacle dot cx 2008-05-10 23:54 --- Now that I'm fixing the -template f() member references in the code it's obvious this one is just a much of a hemorrhoidal pain as the scope rule resolution. It deserves a command switch for turning off the strict behavior. Something like -fdisable-non-intuitive-template-behavior-that-serves-no-real-purpose -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #4 from pinskia at gcc dot gnu dot org 2008-05-10 23:57 --- -fdisable-non-intuitive-template-behavior-that-serves-no-real-purpose It is hard to figure out just from the context of the sources that it is going to be a template or not in some cases. Guessing makes it worse. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #5 from starlight at binnacle dot cx 2008-05-11 00:08 --- Yet Sun, IBM and Microsoft all somehow manage it. Now what was once a clean, elegant and easy to read function is a hideous hairball template function. I've become so frustrated with C++ generics over the last couple of years that I've started to just use M4 macros to accomplish the same result. When done correctly they are just as type-safe and ten times more readable. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #6 from bangerth at dealii dot org 2008-05-11 02:17 --- (In reply to comment #5) Yet Sun, IBM and Microsoft all somehow manage it. But which function do they take in this case: -- void f(); template typename T struct B { void f(); }; template typename T struct D : BT { void g() { f(); } }; --- The standard prescribes that in D::g() the function ::f() is called. Are you suggesting that the compiler pick B::f() instead? Or do you suggest that the compiler picks B::f() if such a function exists, and ::f() otherwise? That wouldn't be very intuitive either. The rules may not always be intuitive, but they're there for a good reason, not to annoy users. W. -- bangerth at dealii dot org changed: What|Removed |Added CC||bangerth at dealii dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #7 from starlight at binnacle dot cx 2008-05-11 02:42 --- That little bit of ambiguity bothers me a lot less that writing 55,000 freaking 'using' statements, which is what I've had to do for several years now. In the real world nobody except idiots name their functions 'f', so it doesn't arise as a practical problem. To the extent it does, writing an occasional ::f() and B::f() are much less of a problem than the hundreds of stupid 'using' statements I've had to write ever since GCC 3.4. The resulting code is much harder to maintain as every time I add some logic I then have spend 30 minutes or an hour chasing down more 'using's. The theoretical side of the issue makes no impression on people who work for living. Have a switch option for masochists who give a s**t. Let me be perfectly clear: Thousands of lines of code worked perfectly fine before this slavish standard nonsense. All that's changed is that people like me who used to like templates like them a lot less now. M4 looks better every day. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #8 from bangerth at dealii dot org 2008-05-11 02:59 --- (In reply to comment #7) That little bit of ambiguity bothers me a lot less that [...] If that's your opinion, then you've never worked with large software systems. Writing a few this- here and there because the compiler complains is a small effort compared to debugging why your code doesn't work. W. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #9 from starlight at binnacle dot cx 2008-05-11 03:14 --- You're speaking of large systems of code written by bad programmers, who by definition should never be let anywhere near C++. Let them write Java and C#, languages that were designed specifically for bad programmers. No class layer should be so large and complex that it isn't quickly obvious when a conflict arises. Any anyone who has large collections of global scope function names, or re-uses function names found in the STL should be shot. On the other hand it easy to write base class template hierarchies with 30 to 50 members referenced in derived classes. You seem to think that writing and maintaining dozens of 'using' statements in each layer is a great way to spend your days. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #10 from starlight at binnacle dot cx 2008-05-11 03:29 --- Oh, and let's not forget about the millions of lines of C++ code written for the Windows platform that will *never* be ported to Linux. How's that for a domain of large software systems? If that scary old ambiguity monster was really so bad, why doesn't VC6,7,8,9 enforce the scope rule? If template member names were such a problem, why does VC8 not demand the '-template f()' syntax? You can mumble bad things about Microsoft all day long, but they sell a lot of software and make a *lot* of money supporting a commercial realm that's surely much larger than the *nix world. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #11 from bangerth at dealii dot org 2008-05-11 03:32 --- (In reply to comment #10) VC6,7,8,9 I suppose that's the compiler you should use then. W. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203
[Bug c++/36203] explicit member function template lookup fails from templated function
--- Comment #12 from starlight at binnacle dot cx 2008-05-11 03:36 --- It could happen. All of our new customers for the last two years run Windows, not Linux. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36203