[LLVMbugs] [Bug 21755] New: In-class initialization with template function call fails to compile

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Dec 4 14:50:18 PST 2014


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

            Bug ID: 21755
           Summary: In-class initialization with template function call
                    fails to compile
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: groszdanireg at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

template<typename T, typename U> int f()
{ 
  return 42;
}
struct C
{ 
  int v=f<int,int>();
};
int main() { return 0; }

This fails to compile:

$ clang -std=c++11 inclass_init_template.cpp 
inclass_init_template.cpp:8:15: error: expected member name or ';' after
      declaration specifiers
  int v=f<int,int>();
  ~~~         ^
inclass_init_template.cpp:8:15: error: expected ';' at end of declaration list
  int v=f<int,int>();
              ^
              ;
inclass_init_template.cpp:8:14: error: expected '>'
  int v=f<int,int>();
             ^
3 errors generated.

It compiles
- if there is one template parameter,
- or if the initialization is placed in the initializer list of a constructor
- or if the same declaration is used to declare a local variable
- or if the function is made to have parameters and its template arguments are
deduced from the parameters,
- or if GCC 4.8.3 is used instead of clang.

-- 
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/20141204/980bb161/attachment.html>


More information about the llvm-bugs mailing list