public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14500] New: most specialized function template vs. non-template function
@ 2004-03-09  4:51 bkoz at gcc dot gnu dot org
  2004-03-09  5:18 ` [Bug c++/14500] " bangerth at dealii dot org
                   ` (24 more replies)
  0 siblings, 25 replies; 28+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2004-03-09  4:51 UTC (permalink / raw)
  To: gcc-bugs

While working on c++/13658, I ran into divergent behavior between icc 7.1 and g++.

I think g++ is wrong, and that in the code below, the explicitly specialized
function template is the most specialized function, and should be called.

By removing the template specialization syntax (ie "template<>"), and trying
again, I get something that is considered the most specialized. But, why this
and not the other?

-benjamin

#include <vector>
#include <cassert>
#define VERIFY assert
 
struct T { int i; };

int swap_calls;

namespace std
{
  // Should be most specialized.
#if 1
  template<> 
#endif
    inline void 
    swap(vector<T, allocator<T> >&, vector<T, allocator<T> >&) 
    { ++swap_calls; }
}

void test01()
{
  bool test __attribute__((unused)) = true;
  std::vector<T> A;
  std::vector<T> B;
  swap_calls = 0;
  std::swap(A, B);
  VERIFY(1 == swap_calls); // XXX fails
}

void test02()
{
  bool test __attribute__((unused)) = true;
  using namespace std;
  vector<T> A;
  vector<T> B;
  swap_calls = 0;
  swap(A, B);
  VERIFY(1 == swap_calls);
}

int main()
{
  test01();
  test02();
  return 0;
}

-- 
           Summary: most specialized function template vs. non-template
                    function
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bkoz at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 28+ messages in thread
[parent not found: <bug-14500-365@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2006-02-28  8:52 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-09  4:51 [Bug c++/14500] New: most specialized function template vs. non-template function bkoz at gcc dot gnu dot org
2004-03-09  5:18 ` [Bug c++/14500] " bangerth at dealii dot org
2004-03-09  7:13 ` gdr at integrable-solutions dot net
2004-03-09  7:13 ` [Bug c++/14500] New: " Gabriel Dos Reis
2004-03-09  7:21 ` [Bug c++/14500] " gdr at integrable-solutions dot net
2004-03-09 14:34 ` pcarlini at suse dot de
2004-03-09 16:34 ` bkoz at redhat dot com
2004-03-10 12:23 ` giovannibajo at libero dot it
2004-03-10 12:28 ` giovannibajo at libero dot it
2004-03-10 15:21 ` gdr at integrable-solutions dot net
2004-03-31  2:28 ` pinskia at gcc dot gnu dot org
2004-04-04  3:00 ` jason at gcc dot gnu dot org
2004-04-04  3:01 ` jason at gcc dot gnu dot org
2004-04-05 23:08 ` jason at gcc dot gnu dot org
2004-04-05 23:16 ` bkoz at redhat dot com
2004-04-05 23:20 ` jason at gcc dot gnu dot org
2004-04-08 20:42 ` jason at redhat dot com
2004-04-14 21:44 ` jason at gcc dot gnu dot org
2004-04-15 11:38 ` giovannibajo at libero dot it
2004-04-15 22:58 ` jason at redhat dot com
2004-06-12 21:51 ` mmitchel at gcc dot gnu dot org
2004-08-29 18:55 ` mmitchel at gcc dot gnu dot org
2004-11-01  0:46 ` mmitchel at gcc dot gnu dot org
2005-02-22  0:12 ` pinskia at gcc dot gnu dot org
2005-05-19 17:30 ` mmitchel at gcc dot gnu dot org
2005-07-23 22:35 ` bangerth at dealii dot org
     [not found] <bug-14500-365@http.gcc.gnu.org/bugzilla/>
2005-10-07  3:15 ` gdr at gcc dot gnu dot org
2006-02-28  8:53 ` gdr at gcc dot gnu dot 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).