GNOME Bugzilla – Bug 131928
G++-3.4 prerelease: Broken template method in Gtk::TreePath.
Last modified: 2004-12-22 21:47:04 UTC
This code is in treepath.hg: template <class In> void TreePath::append(In pbegin, In pend) { // push_back() can't throw -- if it could, this code wouldn't be strongly exception-safe. for(; pbegin != pend; ++pbegin) this->push_back(*begin); } Prerelease G++-3.4 complains about this code, whereas G++-3.2 doesn't. This is presumably due to the new two-stage lookup rules, where I presume some names are resolved before instantiation time. The problem is "begin" needs to be "pbegin". This would have broken in G++-3.2, but I guess no one ever instantiated this method, the following code shows it is broken either way: #include <gtkmm.h> #include <list> int main() { Gtk::TreePath path; std::list< int > a; a.push_back( 1 ); path.append( a.begin(), a.end() ); }
I don't really understand why the this-> is necessary, but I would happily apply a patch with a ChangeLog entry and a comment next to the line so that the this-> is not accidentally removed again later.
It's necessary because the standard requires it. I think it happens when you have a template inheriting from a template, where you need to use this to access supermethods. I thought I saw this a fair bit already in GTKMM, and even if it isn't it will be in a fair few places in the near future, because it is required. I don't think a comment in each place is feasible.
A comment will do no harm.
By the way, this is mentioned in the gcc ChangeLog: http://gcc.gnu.org/gcc-3.4/changes.html
This should be easy to make a patch for.
Just to be clear... you want someone to write up a ChangeLog entry, add a single character to a source file, make a patch out of that, submit it to you, and then you'll look over this single character addition, apply the patch, and put it in?
And _test_ it with the _compiler_ that they have. My time is limited, even for easy stuff.
And it's not a single character, and probably not a single line.
Ah, I see that I completely misunderstood this bug when speed reading it originally. Patches really are easier, you see. The change has been committed. Thanks. By the way, I have no idea why this method is a template.