[LLVMbugs] [Bug 21422] New: spurious diagnostic produced for second use of ill-formed function template specialization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 30 18:01:21 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21422

            Bug ID: 21422
           Summary: spurious diagnostic produced for second use of
                    ill-formed function template specialization
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Testcase:

template<typename T> struct A {
  A() { T::error; }
};
struct B : A<int> {};
template<typename T> struct C : A<T> { C() : A<int>() {} };
B b;
C<int> c;

This produces:

<stdin>:2:9: error: type 'int' cannot be used prior to '::' because it has no
members
  A() { T::error; }
        ^
<stdin>:4:8: note: in instantiation of member function 'A<int>::A' requested
here
struct B : A<int> {};
       ^
<stdin>:5:46: error: no matching constructor for initialization of 'A<int>'
template<typename T> struct C : A<T> { C() : A<int>() {} };
                                             ^
<stdin>:6:13: note: in instantiation of member function 'C<int>::C' requested
here
B b; C<int> c;
            ^
<stdin>:1:29: note: candidate constructor (the implicit copy constructor) not
viable: requires 1 argument, but 0 were provided
template<typename T> struct A {
                            ^

The first error is fine; the second one is bogus. Two issues here:

1) we shouldn't be marking the declaration of the function as invalid just
because we failed to instantiate its definition (but currently this is how we
track that we shouldn't try to instantiate it again, so we'll need another
representation for that if we change this), and
2) if the candidate set contains invalid functions, overload resolution should
always succeed (rather than ignoring those functions), since as far as we know
one of those invalid functions could be intended to match.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141031/d150a033/attachment.html>


More information about the llvm-bugs mailing list