Starting with version 4.0 G++ fails to accept this testcase:

bool f(int i) { return i != 5; }

template <class X, class P = bool(X)>
struct Traits
{
 typedef P type;
};

template <class X, class P = typename Traits<X>::type>
struct S
{
 const P& p_;
 S( const P& p ) : p_(p) {} // const reference
};

template <class X>
S<X> make_s(const typename Traits<X>::type & p) // const reference
{
 return S<X>(p); // << HERE
}

int main()
{
 make_s<int>(f);
}

because the parameter of make_s<int> ends up with reference to const function
type.  This is wrong; applying const to a function type should produce the same
function type, not a const variant.


-- 
           Summary: [4.3/4.4/4.5/4.6 Regression] function types, cv-quals
                    and typename
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: jason at gcc dot gnu dot org
        ReportedBy: jason at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44193

Reply via email to