[LLVMbugs] [Bug 15686] New: Class constructor default argument fails to compile

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 5 05:46:51 PDT 2013


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

            Bug ID: 15686
           Summary: Class constructor default argument fails to compile
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: MyAdEss at seznam.cz
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

If a class constructor has an argument that takes a default value that itself
is a template of more than one parameter, it fails to compile.

Example of a full program:
http://ideone.com/mv9Qco
/***************************************************/
#include <functional>
using namespace std;

/* a function template */
template <typename A, typename B>
A f(B) { return A(); }

/* a class template */
template <typename A, typename B>
class X {};

template <typename A, typename B>
class Y
{
  /** All these constructors fail to compile **/

  Y(X<A,B> = X<A,B>())
  //Y(A (*arg)(B) = f<A, B>)
  //Y(std::function<A(B)> arg = f<A, B>)
  { }
};

int main()
{ return 0; }
/***************************************************/

It compiles successfully on GCC and MSVC.

Compiler error:
clangtest.cpp:17:19: error: expected ')'
  Y(X<A,B> = X<A,B>())
                  ^
clangtest.cpp:17:4: note: to match this '('
  Y(X<A,B> = X<A,B>())
   ^
clangtest.cpp:17:17: error: expected '>'
  Y(X<A,B> = X<A,B>())
                ^
2 errors generated.


--Floop

-- 
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/20130405/4a8a4d17/attachment.html>


More information about the llvm-bugs mailing list