c++/2563: g++ does not apply trivial conversions for operator overloading resolution

spacek@geocities.com spacek@geocities.com
Mon Apr 16 15:16:00 GMT 2001


>Number:         2563
>Category:       c++
>Synopsis:       g++ does not apply trivial conversions for operator overloading resolution
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 16 15:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     spacek@geocities.com
>Release:        gcc version 2.95.3 20010315 (Debian release)
>Organization:
>Environment:

>Description:
g++ does not seem to apply a conversion from an integer
to a double when resolving operator overloading.

The how-to-repeat section contains a very short program
which fails to compile with error message

test.cpp: In function `int main(int, char **)':
test.cpp:18: no match for `Vector<double> & / int'

However, an operator 'Vector<double> & / const double' 
is defined which should (I think) be enough.
>How-To-Repeat:
Feed g++ the following short program. It will complain
about a / operator not defined, which I think is incorrect.

--- EXAMPLE START ---

template <class NT>
class Vector {
private:
        NT data;
};
 
template <class NT> Vector<NT>
operator/ (const Vector<NT> &v, const NT n)
{
}
 
 
int main (int argc, char *argv[])
{
        Vector<double> a, b;
        b = a/2;
}

--- EXAMPLE END ---
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list