public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11752] New: partial ordering overloaded function templates
@ 2003-07-31 18:48 nbecker at fred dot net
2003-07-31 19:08 ` [Bug c++/11752] " pinskia at physics dot uc dot edu
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: nbecker at fred dot net @ 2003-07-31 18:48 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
Summary: partial ordering overloaded function templates
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nbecker at fred dot net
CC: gcc-bugs at gcc dot gnu dot org
In the following example, I believe the call should not be ambiguous, because
the second overloaded Rnd function is more specialized, and partial ordering
should apply:
template<int shift, int size, typename T>
inline T Rnd (T x) {
T y = x >> (shift - 1);
if (y == Sint<size+1>::max)
return y >> 1;
else
return (y + 1) >> 1;
}
template<int shift, int size, typename FLT>
inline std::complex<FLT> Rnd (std::complex<FLT> x) {
return std::complex<FLT> (Rnd<size, shift, FLT> (real (x)), Rnd<size, shift,
FLT> (imag (x)));
}
../Test/Test6.cc:224: call of overloaded `Rnd(std::complex<int>)' is ambiguous
../src/fixed/FixedUtil.H:18: candidates are: T Rnd(T) [with int shift = 6, int
size = 8, T = std::complex<int>]
../src/fixed/FixedUtil.H:27: std::complex<FLT>
Rnd(std::complex<FLT>) [with int shift = 6, int size = 8, FLT = int]
gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
@ 2003-07-31 19:08 ` pinskia at physics dot uc dot edu
2003-07-31 19:16 ` nbecker at hns dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-31 19:08 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Target Milestone|3.4 |---
------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-31 19:08 -------
Can you provide the preprocessed source file?
Read <http://gcc.gnu.org/bugs.html> for how to produce that file.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
2003-07-31 19:08 ` [Bug c++/11752] " pinskia at physics dot uc dot edu
@ 2003-07-31 19:16 ` nbecker at hns dot com
2003-08-04 14:54 ` nbecker at fred dot net
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: nbecker at hns dot com @ 2003-07-31 19:16 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
------- Additional Comments From nbecker at hns dot com 2003-07-31 19:16 -------
Subject: Re: partial ordering overloaded function templates
On Thursday 31 July 2003 03:08 pm, you wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
>
>
> pinskia at physics dot uc dot edu changed:
>
> What |Removed |Added
> ---------------------------------------------------------------------------
>- Status|UNCONFIRMED |WAITING
> Target Milestone|3.4 |---
>
>
> ------- Additional Comments From pinskia at physics dot uc dot edu
> 2003-07-31 19:08 ------- Can you provide the preprocessed source file?
> Read <http://gcc.gnu.org/bugs.html> for how to produce that file.
>
OK, done.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
2003-07-31 19:08 ` [Bug c++/11752] " pinskia at physics dot uc dot edu
2003-07-31 19:16 ` nbecker at hns dot com
@ 2003-08-04 14:54 ` nbecker at fred dot net
2003-08-04 14:58 ` pinskia at physics dot uc dot edu
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: nbecker at fred dot net @ 2003-08-04 14:54 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
nbecker at fred dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
` (2 preceding siblings ...)
2003-08-04 14:54 ` nbecker at fred dot net
@ 2003-08-04 14:58 ` pinskia at physics dot uc dot edu
2003-08-04 14:58 ` pinskia at physics dot uc dot edu
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-04 14:58 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
------- Additional Comments From pinskia at physics dot uc dot edu 2003-08-04 14:58 -------
Changing to invalid to change to ...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
` (3 preceding siblings ...)
2003-08-04 14:58 ` pinskia at physics dot uc dot edu
@ 2003-08-04 14:58 ` pinskia at physics dot uc dot edu
2003-08-04 19:44 ` pinskia at physics dot uc dot edu
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-04 14:58 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
------- Additional Comments From pinskia at physics dot uc dot edu 2003-08-04 14:58 -------
unconfirmed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
` (4 preceding siblings ...)
2003-08-04 14:58 ` pinskia at physics dot uc dot edu
@ 2003-08-04 19:44 ` pinskia at physics dot uc dot edu
2003-08-05 16:29 ` lerdsuwa at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-04 19:44 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
------- Additional Comments From pinskia at physics dot uc dot edu 2003-08-04 19:44 -------
ICC 6.0 in strict mode rejects this:
pr11752.cc(29): error: more than one instance of overloaded function "Rnd" matches the
argument list:
function template "Rnd<shift,size,T>(T)"
function template "Rnd<shift,size,FLT>(std::complex<FLT>)"
argument types are: (ComplexI)
ComplexI z = Rnd <6, 4> (x);
^
compilation aborted for pr11752.cc (code 2)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
` (5 preceding siblings ...)
2003-08-04 19:44 ` pinskia at physics dot uc dot edu
@ 2003-08-05 16:29 ` lerdsuwa at gcc dot gnu dot org
2003-08-05 16:33 ` bangerth at dealii dot org
2003-08-05 16:50 ` nbecker at hns dot com
8 siblings, 0 replies; 10+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2003-08-05 16:29 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
lerdsuwa at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2003-08-05 16:29 -------
Not a bug. According to the standard, partial ordering is defined
based on template argument deduction. Since the parameter 'size'
is not used anywhere in function parameter or return type, it's
not deducable and partial ordering fails. So both are treated as
equal, none is more specialized than the other.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
` (6 preceding siblings ...)
2003-08-05 16:29 ` lerdsuwa at gcc dot gnu dot org
@ 2003-08-05 16:33 ` bangerth at dealii dot org
2003-08-05 16:50 ` nbecker at hns dot com
8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2003-08-05 16:33 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
------- Additional Comments From bangerth at dealii dot org 2003-08-05 16:32 -------
Here's a self-contained testcase:
-----------------------------
template <typename> struct X {};
template<int shift, typename T> T f (T);
template<int shift, typename T> X<T> f (X<T>);
int main () {
X<int> x;
f<6> (x);
}
------------------------------
It fails with 3.4 and icc7:
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c bug.cc
bug.cc: In function `int main()':
bug.cc:8: error: call of overloaded `f(X<int>&)' is ambiguous
bug.cc:3: note: candidates are: T f(T) [with int shift = 6, T = X<int>]
bug.cc:4: note: X<T> f(X<T>) [with int shift = 6, T = int]
g/x>
g/x> icc -c bug.cc
bug.cc(8): error: more than one instance of overloaded function "f" matches the
argument list:
function template "f<shift,T>(T)"
function template "f<shift,T>(X<T>)"
argument types are: (X<int>)
f<6> (x);
^
compilation aborted for bug.cc (code 2)
I recall that we had another PR like this, where the existence of the
first template arg made a difference, and I remember I didn't understand
the reasoning why that was deemed illegal. Note that if the int template
arg is removed (along with the <6> on the call of f), then both
compilers grok the code.
Someone with more knowledge will have to look at this.
W.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/11752] partial ordering overloaded function templates
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
` (7 preceding siblings ...)
2003-08-05 16:33 ` bangerth at dealii dot org
@ 2003-08-05 16:50 ` nbecker at hns dot com
8 siblings, 0 replies; 10+ messages in thread
From: nbecker at hns dot com @ 2003-08-05 16:50 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
------- Additional Comments From nbecker at hns dot com 2003-08-05 16:50 -------
Subject: Re: partial ordering overloaded function templates
On Tuesday 05 August 2003 12:29 pm, you wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11752
>
>
> lerdsuwa at gcc dot gnu dot org changed:
>
> What |Removed |Added
> ---------------------------------------------------------------------------
>- Status|UNCONFIRMED |RESOLVED
> Resolution| |INVALID
>
>
> ------- Additional Comments From lerdsuwa at gcc dot gnu dot org
> 2003-08-05 16:29 ------- Not a bug. According to the standard, partial
> ordering is defined based on template argument deduction. Since the
> parameter 'size'
> is not used anywhere in function parameter or return type, it's
> not deducable and partial ordering fails. So both are treated as
> equal, none is more specialized than the other.
>
>
>
Thank you for clarifying this. Unfortunately, I don't own a copy of the
standard.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-08-05 16:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-31 18:48 [Bug c++/11752] New: partial ordering overloaded function templates nbecker at fred dot net
2003-07-31 19:08 ` [Bug c++/11752] " pinskia at physics dot uc dot edu
2003-07-31 19:16 ` nbecker at hns dot com
2003-08-04 14:54 ` nbecker at fred dot net
2003-08-04 14:58 ` pinskia at physics dot uc dot edu
2003-08-04 14:58 ` pinskia at physics dot uc dot edu
2003-08-04 19:44 ` pinskia at physics dot uc dot edu
2003-08-05 16:29 ` lerdsuwa at gcc dot gnu dot org
2003-08-05 16:33 ` bangerth at dealii dot org
2003-08-05 16:50 ` nbecker at hns dot com
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).