public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13517] New: confusing error message for reference on a constant
@ 2003-12-30 12:49 debian-gcc at lists dot debian dot org
  2003-12-30 17:33 ` [Bug c++/13517] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2003-12-30 12:49 UTC (permalink / raw)
  To: gcc-bugs

[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


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

* [Bug c++/13517] confusing error message for reference on a constant
  2003-12-30 12:49 [Bug c++/13517] New: confusing error message for reference on a constant debian-gcc at lists dot debian dot org
@ 2003-12-30 17:33 ` pinskia at gcc dot gnu dot org
  2003-12-30 18:23 ` falk at debian dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-30 17:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-30 17:17 -------
It is not a special case in the C++ standard at all, the problem is that you are trying to a constant 
and make it a reference which is wrong.  Yes the error message is confussing, I thought I saw a 
bug like this one asking for a better error message.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2003-12-30 17:17:41
               date|                            |


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


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

* [Bug c++/13517] confusing error message for reference on a constant
  2003-12-30 12:49 [Bug c++/13517] New: confusing error message for reference on a constant debian-gcc at lists dot debian dot org
  2003-12-30 17:33 ` [Bug c++/13517] " pinskia at gcc dot gnu dot org
@ 2003-12-30 18:23 ` falk at debian dot org
  2003-12-30 19:45 ` pinskia at gcc dot gnu dot org
  2004-01-01  2:47 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: falk at debian dot org @ 2003-12-30 18:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2003-12-30 18:02 -------
String literals are in fact a sspecial case in the C++ standard, since
there is an implicit conversion to (non-const) char*. It is deprecated though,
and g++ should probably warn about it.

Aso for the error message, I can't find it that bad; it says there's no
matching method, and that's exactly what the problem is. I don't think
g++ should list for every candidate why it doesn't match, these error messages
tend to be long enough as they are.

-- 


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


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

* [Bug c++/13517] confusing error message for reference on a constant
  2003-12-30 12:49 [Bug c++/13517] New: confusing error message for reference on a constant debian-gcc at lists dot debian dot org
  2003-12-30 17:33 ` [Bug c++/13517] " pinskia at gcc dot gnu dot org
  2003-12-30 18:23 ` falk at debian dot org
@ 2003-12-30 19:45 ` pinskia at gcc dot gnu dot org
  2004-01-01  2:47 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-30 19:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-30 19:22 -------
The conversion between strings and char* is another for another PR which is already 
filed as PR 8586.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement


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


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

* [Bug c++/13517] confusing error message for reference on a constant
  2003-12-30 12:49 [Bug c++/13517] New: confusing error message for reference on a constant debian-gcc at lists dot debian dot org
                   ` (2 preceding siblings ...)
  2003-12-30 19:45 ` pinskia at gcc dot gnu dot org
@ 2004-01-01  2:47 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-01  2:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-01 02:47 -------
This is a dup of bug 2112.

*** This bug has been marked as a duplicate of 2112 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2004-01-01  2:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-30 12:49 [Bug c++/13517] New: confusing error message for reference on a constant debian-gcc at lists dot debian dot org
2003-12-30 17:33 ` [Bug c++/13517] " pinskia at gcc dot gnu dot org
2003-12-30 18:23 ` falk at debian dot org
2003-12-30 19:45 ` pinskia at gcc dot gnu dot org
2004-01-01  2:47 ` pinskia 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).