Postincrement causes match problem - bug or feature?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The following code gives a function match error.  If the postincrement
is removed on cp when calling foo(), everything is fine.  Is this a
compiler problem or a user problem?

Thanks:

=================

#include <iostream>

using namespace std;

template <typename T>
int foo(T& t1)
{
  cerr << "Got in #1!\n";
  return 0;
}

int foo(char* & c)
{
  cerr << "Got in #2!\n";
  return 0;
}

int main()
{
  char c = 'c';
  char* cp = &c;

  foo(cp++);
  return (0);
}

==============

test2.cc: In function 'int main()':
test2.cc:23: error: no matching function for call to 'foo(char*)'
test2.cc:6: note: candidates are: int foo(T&) [with T = char*]
test2.cc:12: note:                 int foo(char*&)

==============

$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)

-- 
Andrew Bell
andrew.bell.ia@xxxxxxxxx

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux