c++/3396: template conversion operator

Axel.Zeuner@systor.com Axel.Zeuner@systor.com
Mon Jun 25 00:56:00 GMT 2001


>Number:         3396
>Category:       c++
>Synopsis:       template conversion operator
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 25 00:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Axel Zeuner
>Release:        2.95.2, 3.0-release, 3.0.1 (prerelease)
>Organization:
>Environment:
Solaris 2.6, Linux
>Description:
Conversion operators of templates classes to typenames typedefed in the template class work only in the body.
>How-To-Repeat:
Compile the test program attached.
>Fix:
Implement conversion operators in templates in the class
body.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="main.cpp"
Content-Disposition: inline; filename="main.cpp"

template <class T>
class X {
public:
    typedef T* XY;
    operator XY();
};

template <class T>
X<T>::operator X<T>::XY()
{
    return XY(0);
}

int main()
{
    X<int> p;
    int* pp=p;
    int rc=0;
    if ( pp!= 0) {
	rc=1;
    }
    return rc;
}



More information about the Gcc-bugs mailing list