Postincrement causes match problem - bug or feature?

Andrew Bell
Mon Sep 29 15:19:00 GMT 2008


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?



#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;

  return (0);

============== In function 'int main()': error: no matching function for call to 'foo(char*)' note: candidates are: int foo(T&) [with T = char*] 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-java-awt=gtk --disable-dssi --enable-plugin
--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

More information about the Gcc-help mailing list