This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix PR c++/19439
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Lee Millward <lee dot millward at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 27 Dec 2006 22:40:15 -0800
- Subject: Re: [patch] Fix PR c++/19439
- References: <9784d3ab0612201624s57442d0btd7c0e4438a55dac2@mail.gmail.com>
Lee Millward wrote:
> Hi,
>
> This bug is an accepts-invalid with the following testcase:
>
> template<int> struct A
> {
> ~A() {}
> ~A() {}
> };
>
> The reason for this code being accepted can be tracked down to the
> following comment in add_method(): "TYPE is a template class. Don't
> issue any errors now; wait until instantiation time to complain", the
> problem being in this case the template isn't instantiated so no
> diagnostic is issued.
:REVIEWMAIL: OK
I was nervous about this patch because I suspected that with the patch
we'll warn twice about duplicates in templates: first when declaring the
class, and again when instantiating it.
The problem is that it's hard to avoid warning when instantiating.
There's no way to know if:
template <typename T>
struct S {
void f(int);
void f(T);
};
contains a duplicate until we know what "T" is -- anything but
cv-qualified "int" is OK.
However, it looks like your patch will be OK because you will only error
out on the uninstantiated template if the method is definitely a
duplicate, and then we'll not add the function to the class, and so
we'll not get another error upon instantiation.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713