public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/4672: Template parameter deduction fails for overloaded template functions.
@ 2001-12-29 8:31 nathan
0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2001-12-29 8:31 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nathan, nobody, sven
Synopsis: Template parameter deduction fails for overloaded template functions.
Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-By: nathan
Responsible-Changed-When: Sat Dec 29 08:31:32 2001
Responsible-Changed-Why:
patch in progress
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4672
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/4672: Template parameter deduction fails for overloaded template functions.
@ 2001-10-27 4:45 lerdsuwa
0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2001-10-27 4:45 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, sven
Synopsis: Template parameter deduction fails for overloaded template functions.
State-Changed-From-To: open->analyzed
State-Changed-By: lerdsuwa
State-Changed-When: Sat Oct 27 04:45:45 2001
State-Changed-Why:
Confirm as a bug.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4672&database=gcc
^ permalink raw reply [flat|nested] 3+ messages in thread
* c++/4672: Template parameter deduction fails for overloaded template functions
@ 2001-10-25 16:26 sven
0 siblings, 0 replies; 3+ messages in thread
From: sven @ 2001-10-25 16:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 4672
>Category: c++
>Synopsis: Template parameter deduction fails for overloaded template functions.
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Oct 25 16:26:12 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Sven Rosvall
>Release: 3.0
>Organization:
>Environment:
System: Linux harold.prqa.ie 2.2.14-6.1.1smp #1 SMP Thu Apr 13 19:55:55 EDT 2000 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure
>Description:
This works fine with GCC 2.95.1 but not with 2.96 or 3.0.
We have also compared this code with the Comeau C/C++ 4.2.45.2
compiler for a third oppinion. It accepts the code without any
errors.
The problem is with template parameter deduction when there are two
overloaded template functions. One is taking a reference and the other
pointer.
//Code example:
// checked_cast is intended to work as static_cast but for debug
// builds it will check that the cast is correct.
template<class T, class U> inline T checked_cast(U & from)
{
try
{
dynamic_cast <T> (from);
}
catch (...)
{
// Error
}
return static_cast<T>(from);
}
template <class T, class U> inline T checked_cast(U * from)
{
if (! dynamic_cast <T>(from))
{
// Error
}
return static_cast <T>(from);
}
class A
{
public:
virtual ~A();
};
class C;
class B : public A
{
void foo () const;
};
class C : public B
{
};
void B::foo () const
{
C const & c1 = checked_cast <C const &> (*this);
C const * c2 = checked_cast <C const *> (this);
}
Output from g++ (3.0)
/usr/local/bin/new-fronts/g++ -v input.cc
Reading specs from /usr/local/bin/new-fronts/../lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ./configure
Thread model: single
gcc version 3.0
/usr/local/bin/new-fronts/../lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -v -iprefix /usr/local/bin/new-fronts/../lib/gcc-lib/i686-pc-linux-gnu/3.0/ -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ input.cc -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase input.cc -version -o /tmp/ccp1UP1Q.s
GNU CPP version 3.0 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 (i686-pc-linux-gnu)
compiled by GNU C version 3.0.
ignoring duplicate directory "/usr/local/include/g++-v3"
ignoring duplicate directory "/usr/local/include/g++-v3/i686-pc-linux-gnu"
ignoring duplicate directory "/usr/local/include/g++-v3/backward"
ignoring duplicate directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/include"
ignoring duplicate directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/bin/lib/../include/g++-v3
/usr/local/bin/lib/../include/g++-v3/i686-pc-linux-gnu
/usr/local/bin/lib/../include/g++-v3/backward
/usr/local/bin/lib/gcc-lib/i686-pc-linux-gnu/3.0/include
/usr/local/bin/lib/../i686-pc-linux-gnu/include
/usr/local/include
/usr/include
End of search list.
input.cc: In member function `void B::foo() const':
input.cc:44: call of overloaded `U_checked_cast(const B* const)' is ambiguous
input.cc:2: candidates are: T U_checked_cast(U&) [with T = const C*, U = const
B* const]
input.cc:15: T U_checked_cast(U*) [with T = const C*, U = const
B]
Output from g++ (2.95.1)
g++ -v input.cc
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs
gcc driver version 2.95.2 19991024 (release) executing gcc version 2.95.1
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ input.cc /tmp/ccNhfq7X.ii
GNU CPP version 2.95.1 19990816 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../include/g++-3
/usr/local/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../i686-pc-linux-gnu/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cc1plus /tmp/ccNhfq7X.ii -quiet -dumpbase input.cc -version -o /tmp/ccSDYmSL.s
GNU C++ version 2.95.1 19990816 (release) (i686-pc-linux-gnu) compiled by GNU C version 2.95.1 19990816 (release).
as -V -Qy -o /tmp/cc1jJrLA.o /tmp/ccSDYmSL.s
[snip]
>How-To-Repeat:
>Fix:
The workaround we use is to specify two parameters to checked_cast.
This works but does not look as nice as it is intended to tod.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-12-29 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-29 8:31 c++/4672: Template parameter deduction fails for overloaded template functions nathan
-- strict thread matches above, loose matches on Subject: below --
2001-10-27 4:45 lerdsuwa
2001-10-25 16:26 sven
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).