public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/2563: g++ does not apply trivial conversions for operator overloading resolution
@ 2001-04-16 16:46 Ross Smith
  0 siblings, 0 replies; 2+ messages in thread
From: Ross Smith @ 2001-04-16 16:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2563; it has been noted by GNATS.

From: Ross Smith <ross.s@ihug.co.nz>
To: spacek@geocities.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/2563: g++ does not apply trivial conversions for operator 
 overloading resolution
Date: Tue, 17 Apr 2001 11:45:38 +1200

 spacek@geocities.com wrote:
 > 
 > 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.
 
 Not a bug. See sections 14.8.3 and 14.8.2.1 of the C++ standard. Type
 conversions are not considered when deducing argument types for function
 templates; only exact matches are allowed, apart from cv-qualification
 and a few other trivial conversions.
 
 -- 
 Ross Smith <ross.s@ihug.co.nz> The Internet Group, Auckland, New Zealand
 ========================================================================
         "Hungarian notation is the tactical nuclear weapon of
          source code obfuscation techniques." -- Roedy Green


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/2563: g++ does not apply trivial conversions for operator overloading resolution
@ 2001-04-16 15:16 spacek
  0 siblings, 0 replies; 2+ messages in thread
From: spacek @ 2001-04-16 15:16 UTC (permalink / raw)
  To: gcc-gnats

>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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-16 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-16 16:46 c++/2563: g++ does not apply trivial conversions for operator overloading resolution Ross Smith
  -- strict thread matches above, loose matches on Subject: below --
2001-04-16 15:16 spacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).