* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
@ 2005-04-02 0:58 ` kjd at duda dot org
2005-04-02 6:16 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kjd at duda dot org @ 2005-04-02 0:58 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |kjd at duda dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
2005-04-02 0:58 ` [Bug c++/20724] " kjd at duda dot org
@ 2005-04-02 6:16 ` pinskia at gcc dot gnu dot org
2005-04-02 14:27 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-02 6:16 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
2005-04-02 0:58 ` [Bug c++/20724] " kjd at duda dot org
2005-04-02 6:16 ` pinskia at gcc dot gnu dot org
@ 2005-04-02 14:27 ` pinskia at gcc dot gnu dot org
2005-07-23 21:29 ` bangerth at dealii dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-02 14:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-02 14:27 -------
Confirmed (fixed up testcase for -pedantic):
namespace N {
int foo ( char * ) { return 200; }
template< typename T > int foo();
}
enum Enum { enum1 };
int foo( Enum const & ) { return 100; }
int main() {
using N:: foo;
foo( enum1 );
}
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-04-02 14:27:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
` (2 preceding siblings ...)
2005-04-02 14:27 ` pinskia at gcc dot gnu dot org
@ 2005-07-23 21:29 ` bangerth at dealii dot org
2005-07-24 17:57 ` kjd at duda dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-07-23 21:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-07-23 21:27 -------
gcc is actually correct. Per the using declaration in main(), you
introduce N::foo into the scope of foo(), and when foo(enum1) is called
we find the name foo inside namespace N and then stop to search, so ::foo
isn't found in any case.
What then happens is this: gcc has one non-template and one template, none
of which match the function argument, so it says that there is no matching
function.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
` (3 preceding siblings ...)
2005-07-23 21:29 ` bangerth at dealii dot org
@ 2005-07-24 17:57 ` kjd at duda dot org
2005-07-24 18:21 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kjd at duda dot org @ 2005-07-24 17:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kjd at duda dot org 2005-07-24 17:33 -------
I will admit I've had difficulty understanding the interaction between scope
searching and overload resolution, but I cannot believe gcc is handling this
right. Consider the example program:
/* 1 */ namespace N {
/* 2 */ int foo ( char * ) { return 200; }
/* 3 */ template< typename T > int foo();
/* 4 */ }
/* 5 */ enum Enum { enum1 };
/* 6 */ int foo( Enum const & ) { return 100; }
/* 7 */ int main() {
/* 8 */ using N:: foo;
/* 9 */ foo( enum1 );
/* 10 */ }
When resolving the call on line 9, either gcc should search the root namespace
or it should stop after finding "foo" in namespace N. Whether it searches the
root namespace should not depend on whether or not one of the overloads in
namespace N is a template. Yet with gcc, the program compiles when line 3 is
commented out, and fails to compile when line 3 is included. You can add more
non-matching foo()'s to namespace N, and the program continues to compile, as
long as none of them is a template.
If Wolfgang's logic in comment 2 were right, then this program would not
compile:
namespace N {
int foo ( char * ) { return 200; }
int foo() { return 300; }
int foo( int, int ) { return 400; }
}
enum Enum { enum1 };
int foo( Enum const & ) { return 100; }
int main() {
using N:: foo;
foo( enum1 );
}
but in fact, it does.
-Ken
(In reply to comment #2)
> gcc is actually correct. Per the using declaration in main(), you
> introduce N::foo into the scope of foo(), and when foo(enum1) is called
> we find the name foo inside namespace N and then stop to search, so ::foo
> isn't found in any case.
>
> What then happens is this: gcc has one non-template and one template, none
> of which match the function argument, so it says that there is no matching
> function.
>
> W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
` (4 preceding siblings ...)
2005-07-24 17:57 ` kjd at duda dot org
@ 2005-07-24 18:21 ` pinskia at gcc dot gnu dot org
2005-07-24 19:28 ` gdr at integrable-solutions dot net
2005-07-25 14:26 ` bangerth at dealii dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-24 18:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-24 18:02 -------
Both ICC and Comeau accept this.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
` (5 preceding siblings ...)
2005-07-24 18:21 ` pinskia at gcc dot gnu dot org
@ 2005-07-24 19:28 ` gdr at integrable-solutions dot net
2005-07-25 14:26 ` bangerth at dealii dot org
7 siblings, 0 replies; 9+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-07-24 19:28 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2005-07-24 18:21 -------
Subject: Re: function overload resolution fails when any template is declared
"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Both ICC and Comeau accept this.
just a note that since ICC and como are now using the same brand of
front-ends, it may indeed seem strange if they did not agree :-p
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20724] function overload resolution fails when any template is declared
2005-04-02 0:56 [Bug c++/20724] New: function overload resolution fails when any template is declared kjd at duda dot org
` (6 preceding siblings ...)
2005-07-24 19:28 ` gdr at integrable-solutions dot net
@ 2005-07-25 14:26 ` bangerth at dealii dot org
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-07-25 14:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-07-25 14:25 -------
As for the initial testcase (Andrew's testcase in comment #1),
- gcc3.3 rejects it with and without the template declaration
- icc rejects it with and without the template declaration
- gcc3.4 (and later) rejects it with the template, but accepts it without
the template calling ::foo
I believe that the later gcc compilers are in error. They should reject the
code.
Anyone has other opinions?
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20724
^ permalink raw reply [flat|nested] 9+ messages in thread