This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR c++/19439


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]