This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA (libstdc++): C++/v3 PATCH for c++/24163 (lookup in dependent bases) and c++/29131
- From: Christopher Jefferson <chris at bubblescope dot net>
- To: Joe Buck <Joe dot Buck at synopsys dot COM>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>, Benjamin Kosnik <bkoz at redhat dot com>, libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 20 May 2011 20:45:38 +0100
- Subject: Re: RFA (libstdc++): C++/v3 PATCH for c++/24163 (lookup in dependent bases) and c++/29131
- References: <4DD69790.8070101@redhat.com> <20110520193035.GA30195@synopsys.com>
On 20 May 2011, at 20:30, Joe Buck wrote:
> On Fri, May 20, 2011 at 09:32:16AM -0700, Jason Merrill wrote:
>> G++ has had a long-standing bug with unqualified name resolution in
>> templates: if we didn't find any declaration when looking up a name in
>> the template definition, we would do an additional unqualified lookup at
>> the point of instantiation. This led to incorrectly finding
>> namespace-scope functions declared later (29131) and member functions of
>> dependent bases (24163). This patch fixes that bug.
>
> I get the impression that most competing C++ compilers (other than the
> old HP compiler) were (or are) very loose about that rule.
>
>> To be friendly to users, the patch also allows affected code to compile
>> with -fpermissive and provides suggestions about how to fix the code:
>> either declaring the desired function earlier (29131) or explicitly
>> qualifying the name with this-> or Class:: (24163).
>
> I think that it's quite likely that there is a lot of C++ code out there
> that depends on this bug to compile. So I'm glad that you've included
> user guidance in the error messages, and it would be interesting to see
> how much code is affected when, say, compiling a distro.
Fortunately clang already implements this rule correctly, so many code bases are already getting fixed. I personally (with a couple of other people) fixed dozens of places in boost where this was breaking code. I expect this to break huge amounts of code in g++-only code bases, but will also help improve compatibility with other compilers.
I could see the temptation to introduce this as a mandatory warning for a while, and only add it under -pedantic. However, it might be easier to just force people to fix their code.
Chris