Bug 27038

Summary: parse error for argument default whose type has two template arguments
Product: gcc Reporter: Geoffrey Irving <irving>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bangerth, faheem, gcc-bugs, igodard, irving, jfranzoy, liu_gw, loewis, nathan, pinskia, prez, reichelt, schoenebeck, sstrasser, uwe.arzt
Priority: P3    
Version: 4.0.1   
Target Milestone: ---   
Host: x86_64-unknown-linux-gnu Target: x86_64-unknown-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed:

Description Geoffrey Irving 2006-04-05 01:43:32 UTC
Compiling the code

  // start tmp.cpp
  template<class T,class S> struct A{};

  struct B
  {   
      void f(A<int,int> default_value=A<int,int>());
  };
  // end tmp.cpp

with

  g++ tmp.cpp

produces these errors

tmp.cpp:6: error: expected ‘,’ or ‘...’ before ‘>’ token
tmp.cpp:6: error: missing ‘>’ to terminate the template argument list
tmp.cpp:6: error: wrong number of template arguments (1, should be 2)
tmp.cpp:2: error: provided for ‘template<class T, class S> struct A’
tmp.cpp:6: error: expected ‘,’ before ‘int’

The errors disappear if
  1. The function is moved outside of the second struct definition.
  2. The second template argument to A is removed.
  3. The default argument is removed.
  4. A typedef is used to encapsulate A<int,int>.
  5. Comeau 4.3.3 is used.
Comment 1 Andrew Pinski 2006-04-05 01:57:20 UTC
This is a dup of bug 57 and in fact an issue with the standard as this is Defect report 325 for the C++ standard.  According to the current standard as written, GCC is correct to reject this code.

*** This bug has been marked as a duplicate of 57 ***