Bug 27038 - parse error for argument default whose type has two template arguments
Summary: parse error for argument default whose type has two template arguments
Status: RESOLVED DUPLICATE of bug 57
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-05 01:43 UTC by Geoffrey Irving
Modified: 2006-04-05 01:57 UTC (History)
15 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***