https://bugs.llvm.org/show_bug.cgi?id=51070

            Bug ID: 51070
           Summary: Forward declared literal type template arg error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: nat...@acm.org
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

Created attachment 25018
  --> https://bugs.llvm.org/attachment.cgi?id=25018&action=edit
testcase

Using a forward declared literal type in a forward declaration of a template
leads to (at best) a confusing error when the template is defined. Clang claims
the parameter has a different type in the two template declarations.  I've not
checked the std, but IMHO either the forward declaration 
  template<Literal key> struct S;
should be rejected as Literal is incomplete, or the later redeclaration of that
template is valid.  Note we don't instantiate S until Literal is defined.

(1)bester:14>bin/clang++ -std=c++20 -c a.cc -DNO_REDECL
bester:15>bin/clang++ -std=c++20 -c a.cc            
a.cc:5:18: error: non-type template parameter has incomplete type 'Literal'
template<Literal key> struct S;
                 ^
a.cc:2:8: note: forward declaration of 'Literal'
struct Literal;
       ^
a.cc:13:18: error: template non-type parameter has a different type 'Literal'
in template redeclaration
template<Literal key>
                 ^
a.cc:5:18: note: previous non-type template parameter with type 'int' is here
template<Literal key> struct S;
                 ^
a.cc:18:6: error: implicit instantiation of undefined template 'S<1>'
S<1> x ;
     ^
a.cc:5:30: note: template is declared here
template<Literal key> struct S;
                             ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to