public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10690: bogus ambiguity on templates overloaded on return type
@ 2003-05-08 19:56 giovannibajo
0 siblings, 0 replies; 3+ messages in thread
From: giovannibajo @ 2003-05-08 19:56 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, sebor
Synopsis: bogus ambiguity on templates overloaded on return type
State-Changed-From-To: open->analyzed
State-Changed-By: bajo
State-Changed-When: Thu May 8 19:56:08 2003
State-Changed-Why:
Using __PRETTY_FUNCTION__, the code compiles correctly on
both 3.3 and 3.4 (CVS 20030503). Thus, the bug is more like this:
---------------------------------------
#include <typeinfo>
template <int VAL>
void func(void) {}
void foo(void)
{
typeid(func<10>);
}
---------------------------------------
pr10690.cpp: In function `void foo()':
pr10690.cpp:8: error: insufficient contextual information to determine type
I believe the code should compile (see also DR115, even if
it does not take into account typeid() but only situations
where the overload set must decay to function pointer). It
works with the EDG frontend but not with MSVC7.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10690
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/10690: bogus ambiguity on templates overloaded on return type
@ 2003-05-08 20:56 Martin Sebor
0 siblings, 0 replies; 3+ messages in thread
From: Martin Sebor @ 2003-05-08 20:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/10690; it has been noted by GNATS.
From: Martin Sebor <sebor@roguewave.com>
To: gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: c++/10690: bogus ambiguity on templates overloaded on return
type
Date: Thu, 08 May 2003 14:51:19 -0600
No, typeid (foo<T>) is what I wanted. There is exactly one foo<T>
for each of the three arguments of T in the program, and they are:
foo<bool>, foo<short>, and foo<int>. typeid(foo<T>).name() should
return the name of each specialization. Note that while Intel C++
gives an ICE, the latest EDG front end, eccp 3.2, that's coming
out in a few days, is supposed to compile the code correctly. The
oly other compiler that I know of that compiles the code is IBM
VAC++ 6.0 (although it fails to link, not sure why).
Martin
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10690
^ permalink raw reply [flat|nested] 3+ messages in thread
* c++/10690: bogus ambiguity on templates overloaded on return type
@ 2003-05-08 18:46 sebor
0 siblings, 0 replies; 3+ messages in thread
From: sebor @ 2003-05-08 18:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 10690
>Category: c++
>Synopsis: bogus ambiguity on templates overloaded on return type
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 08 18:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: sebor@roguewave.com
>Release: 3.2.2
>Organization:
>Environment:
>Description:
The attached well-formed program inspired by the CUJ 6/03 article "Function Overloading Based on Arbitrary
Properties of Types," fails to compile with gcc 3.2.2.
The errors after replacing the dependency on <typeinfo>
with __PRETTY_FUNCTION__ are:
t.cpp:24: new declaration `template<class T> select<(!is_int<T>::value),
T>::type foo(T)'
t.cpp:17: ambiguates old declaration `template<class T>
select<is_int<T>::value, T>::type foo(T)'
Regards
Martin
>How-To-Repeat:
$ cat t.cpp && g++ --version && g++ t.cpp
#include <typeinfo>
template <bool B, class T>
struct select { typedef T type; };
template <class T>
struct select<false, T> { };
template <class T>
struct is_int { enum { value }; };
template <>
struct is_int<int> { enum { value = 1 }; };
extern "C" int printf (const char*, ...);
template <class T>
typename select<is_int<T>::value, T>::type
foo (T t) {
printf ("%s:%d: %s\n", __FILE__, __LINE__, typeid (foo<T>).name ());
return t;
}
template <class T>
typename select<!is_int<T>::value, T>::type
foo (T t) {
printf ("%s:%d: %s\n", __FILE__, __LINE__, typeid (foo<T>).name ());
return t;
}
int main ()
{
foo (bool ());
foo (short ());
foo (int ());
}
g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
t.cpp:26: new declaration `template<class T> select<(!is_int<T>::value),
T>::type foo(T)'
t.cpp:19: ambiguates old declaration `template<class T>
select<is_int<T>::value, T>::type foo(T)'
t.cpp: In function `select<(!is_int<T>::value), T>::type foo(T) [with T =
bool]':
t.cpp:33: instantiated from here
t.cpp:27: insufficient contextual information to determine type
t.cpp: In function `select<(!is_int<T>::value), T>::type foo(T) [with T = short
int]':
t.cpp:34: instantiated from here
t.cpp:27: insufficient contextual information to determine type
t.cpp: In function `select<is_int<T>::value, T>::type foo(T) [with T = int]':
t.cpp:35: instantiated from here
t.cpp:20: insufficient contextual information to determine type
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-05-08 20:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-08 19:56 c++/10690: bogus ambiguity on templates overloaded on return type giovannibajo
-- strict thread matches above, loose matches on Subject: below --
2003-05-08 20:56 Martin Sebor
2003-05-08 18:46 sebor
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).