c++/7468: prototype "doesn't match" a candidate that is actually a perfect match.

carlo@alinoe.com carlo@alinoe.com
Thu Aug 1 19:56:00 GMT 2002


>Number:         7468
>Category:       c++
>Synopsis:       prototype "doesn't match" a candidate that is actually a perfect match.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 01 19:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     carlo@alinoe.com
>Release:        all releases (2.95, 2.96, 3.0.x, 3.1)
>Organization:
>Environment:

>Description:
The compiler aborts compilation with an error
along the lines off:

troep.cc:10: prototype for `bitset<n>::bitset(int (*)[bitset<n>::digits])' does
   not match any in class `bitset<n>'
troep.cc:6: candidate is: bitset<n>::bitset(int (*)[bitset<n>::digits])
>How-To-Repeat:
Compile this:

template<unsigned int n>
  class bitset {
    public:
      static int const digits = 4;
      typedef int foo_t[digits];
      bitset(foo_t*);
  };

template<unsigned int n>
  bitset<n>::bitset(foo_t*) { }

Note that the error goes away
when either
1) the template is removed
2) the static const is removed and '4' is put directly in the typedef
3) the typedef is replaced by a more normal typedef
4) the (foo_t*) is replaced with (foo_t)

Very peculiar bug.
>Fix:
Put the body inside the class declaration.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list