public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49637] New: template function overload incorrectly ambiguous
@ 2011-07-05  2:04 timothyjgiese at gmail dot com
  2011-07-05  2:05 ` [Bug c++/49637] " timothyjgiese at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: timothyjgiese at gmail dot com @ 2011-07-05  2:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49637

           Summary: template function overload incorrectly ambiguous
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: timothyjgiese@gmail.com


Created attachment 24685
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24685
gcc -v -save-temps main.cpp [[stderr]]

The following code works fine with gcc 4.4.3 20100127 (and I'm pretty sure it
worked with 4.6.0 before I updated gcc-c++ yesterday); so maybe this is a
regression from a relatively recent change.

Here's the minimal test case:


struct S { typedef int iterator; };
template <typename T, typename U> void F( typename T::iterator, U   ) {}
template <typename T>             void F( typename T::iterator, int ) {}
int main()
{
  S::iterator i(42);
  F<S>(i,1); // FAILS=4.6.0 20110530 ; OK=4.4.3 20100127
  return 0;
}


g++ without any other options produces the following (incorrect) error:

main.cpp: In function ‘int main()’:
main.cpp:7:11: error: call of overloaded ‘F(S::iterator&, int)’ is ambiguous
main.cpp:7:11: note: candidates are:
main.cpp:2:40: note: void F(typename T::iterator, U) [with T = S, U = int,
typename T::iterator = int]
main.cpp:3:28: note: void F(typename T::iterator, int) [with T = S, typename
T::iterator = int]

Earlier version of g++ did not produce this error.

Note that if I change the definition of F to void F(T,U) and void F(T,int) and
pass in S::iterator as the template argument, then it compiles without error.  
So, it's somehow having a problem with the typename with deduction.

I'd be appreciative if someone simply confirmed if this is a bug or not.
I have a lot of code that fails now that didn't fail a few days ago, and I'm
now wondering if I need to change my code or change back to an older compiler
until this gets resolved.


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

end of thread, other threads:[~2011-09-26 21:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-05  2:04 [Bug c++/49637] New: template function overload incorrectly ambiguous timothyjgiese at gmail dot com
2011-07-05  2:05 ` [Bug c++/49637] " timothyjgiese at gmail dot com
2011-07-05 12:43 ` redi at gcc dot gnu.org
2011-07-05 15:41 ` timothyjgiese at gmail dot com
2011-07-05 16:04 ` timothyjgiese at gmail dot com
2011-07-05 16:37 ` schaub.johannes at googlemail dot com
2011-07-05 17:29 ` redi at gcc dot gnu.org
2011-07-05 17:34 ` timothyjgiese at gmail dot com
2011-07-05 18:02 ` timothyjgiese at gmail dot com
2011-07-05 19:48 ` jason at gcc dot gnu.org
2011-07-05 19:51 ` jason at gcc dot gnu.org
2011-07-05 21:06 ` timothyjgiese at gmail dot com
2011-09-26 22:47 ` jason at gcc dot gnu.org

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).