c++/8158: Compiler rejects legal default parameter

m.doppler@icoserve.com m.doppler@icoserve.com
Mon Oct 7 05:56:00 GMT 2002


>Number:         8158
>Category:       c++
>Synopsis:       Compiler rejects legal default parameter
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 07 05:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Michael Doppler, Peter Klotz
>Release:        gcc 3.2, gcc 3.1
>Organization:
>Environment:
Redhat 8.0, gcc 3.2, glibc 2.2.93
Redhat 7.2, gcc 3.1, glibc 2.2.4
>Description:
The following code doesn't compile although it should.

#include <map>

class A
{
public:
typedef std::map<unsigned char,int> TType;
        //A(const TType& x=TType()) // this works
        A( const std::map<unsigned char, int> & p_map = std::map<unsigned char, int>() ) // this doesn't
        {
        }
};

int main(void )
{
        A a;
        return 0;
}
>How-To-Repeat:
Compile program from description.
>Fix:
Workaround: use typedef provided in code snippet.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list