[Bug c++/13517] New: confusing error message for reference on a constant

debian-gcc at lists dot debian dot org gcc-bugzilla@gcc.gnu.org
Tue Dec 30 12:49:00 GMT 2003


[forwarded from http://bugs.debian.org/216209]

seen with 3.3.2.

The following program consists of two classes, both with a
parametrized method. Depending on the parameter type g++ the
compilation fails or not...

-- snip --
class E1 {
public:
  template <class T>
  void print(T bla) { };
};

class E2 {
public:
  // same as above but with a reference
  template <class T>
  void print(T& bla) { };
};

void foo1() {
  E1 e;

  // works
  e.print("hurz");

  // works too
  e.print(23);
};

void foo2() {
  E2 e;

  // works
  e.print("hurz");

  // fails!
  e.print(23);
};

int main () {  
};
-- snip --

riff /tmp> g++ -Wall temptest1.cc
temptest1.cc: In function `void foo2()':
temptest1.cc:33: error: no matching function for call to
`E2::print(int)'
temptest1.cc:13: error: candidates are: void E2::print(T&) [with T =
int]
Exitcode 1
riff /tmp> g++ --version
g++ (GCC) 3.3.2 20031005 (Debian prerelease)
[...]

This behavoir is at least inconsistent and I believe it to be
buggy. However, the Intel Compiler fails on the same line, so maybe
it's a special case in the C++-specs?!

Cheers
   Thimo

Followup:

I asked a second person when I filed the original bug report but now a
third person saw the problem. Yes, the call tries to create a
reference on a constant and thus cannot compile. But in that case, the
error-message is very misleading.

I've already changed the bug title and changed the severity to
wishlist.

Cheers
   Thimo

-- 
           Summary: confusing error message for reference on a constant
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list