[LLVMbugs] [Bug 11381] New: out-of-line definition of 'curr::f' differ from the declaration in the return type

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 15 04:19:36 PST 2011


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

             Bug #: 11381
           Summary: out-of-line definition of 'curr::f' differ from the
                    declaration in the return type
           Product: clang
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: zilla at kayari.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


template <typename T>
class dep_base
{ };

struct nondep_base
{
  typedef int type;
};

template <typename T>
  struct curr
  : dep_base<T>
  , nondep_base
  {
    type f();
  };


template <typename T>
  typename curr<T>::type
  curr<T>::f()
  {
    return 1;
  }

This gives:

/tmp/webcompile/_3316_0.cc:21:12: error: out-of-line definition of 'curr::f'
differ from the declaration in the return type
  curr<T>::f()
           ^
/tmp/webcompile/_3316_0.cc:15:10: note: previous declaration is here
    type f();
         ^
1 error generated.


I know clang++ does a lot of checks on uninstantiated templates and catches
things other compilers miss, but I don't think this is one of those cases. 
This is related to core DR 1043 but I've read the resolution and although I'm
not 100% certain, I think this is well-formed according to the clarified
wording.


'type' (in the class template definition) and 'curr<T>::type' (in the member
function definition) are both members of the current instantiation according to
14.6.2.1 [temp.dep.type] paragraph 4.


The new paragraph 7 has a note which seems directly relevant, and in this case
no member with the same name is introduced by the dependent base in the
instantiation context.

Am I missing something elsewhere that makes this ill-formed?



As a more minor point, the diagnostic should say "differs" not "differ", and
the phrasing is a bit clunky - it could be read as "differs from [the
declaration in the return type]" implying a declaration in a return type (which
is not legal), whereas it actually means "differs in the return type, from the
declaration"

I would suggest:
out-of-line definition of 'curr::f' has a different return type to the
declaration

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list