public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28330] finds wrong template overload; peculiar diagnostic
  2006-07-10 20:11 [Bug c++/28330] New: finds wrong template overload; peculiar diagnostic igodard at pacbell dot net
@ 2006-07-10 20:11 ` igodard at pacbell dot net
  2006-07-10 20:12 ` igodard at pacbell dot net
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: igodard at pacbell dot net @ 2006-07-10 20:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from igodard at pacbell dot net  2006-07-10 20:11 -------
Created an attachment (id=11855)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11855&action=view)
compiler output -v


-- 


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


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

* [Bug c++/28330]  New: finds wrong template overload; peculiar diagnostic
@ 2006-07-10 20:11 igodard at pacbell dot net
  2006-07-10 20:11 ` [Bug c++/28330] " igodard at pacbell dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: igodard at pacbell dot net @ 2006-07-10 20:11 UTC (permalink / raw)
  To: gcc-bugs

The error is an invocation of operator<<(ring<cacheRequest>&, loadRequest*).
ring<cacheRequest> defines operator<<(ring<cacheRequest>&, cacheRequest*), and 
cacheRequest is a public base of the actual loadRequest argument. If the right 
argument is explicitly cast to cacheRequest* (as shown in the line immediately 
before the reported error) the correct operator<< is found and invoked.

However, when the argument is the derived class the compiler finds and invokes 
an irrelevant definition of operator<< and then blows up inside it. The 
definition it finds is declared by template wideUint<size_t> and in particular 
by wideUint<1>: operator<<(wideUint<1>, const uint32_t&). Somehow it seems to 
decide that it can turn a ring<cacheRequest>& into a wideUint<1>, and then 
complains that it can't turn a cacheRequest* into a uint32_t (which is a
typedef 
for unsigned int).

It seems to me that the compiler should be able to match the intended operator 
by converting to the base class. However, even if it cannot then shouldn't it 
just say "no match found for ..." rather than accepting the bogus match and
then 
complaining about the conversion to uint32_t?


-- 
           Summary: finds wrong template overload; peculiar diagnostic
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net


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


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

* [Bug c++/28330] finds wrong template overload; peculiar diagnostic
  2006-07-10 20:11 [Bug c++/28330] New: finds wrong template overload; peculiar diagnostic igodard at pacbell dot net
  2006-07-10 20:11 ` [Bug c++/28330] " igodard at pacbell dot net
@ 2006-07-10 20:12 ` igodard at pacbell dot net
  2006-07-11  8:29 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: igodard at pacbell dot net @ 2006-07-10 20:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from igodard at pacbell dot net  2006-07-10 20:11 -------
Created an attachment (id=11856)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11856&action=view)
save-temps source (compressed)


-- 


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


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

* [Bug c++/28330] finds wrong template overload; peculiar diagnostic
  2006-07-10 20:11 [Bug c++/28330] New: finds wrong template overload; peculiar diagnostic igodard at pacbell dot net
  2006-07-10 20:11 ` [Bug c++/28330] " igodard at pacbell dot net
  2006-07-10 20:12 ` igodard at pacbell dot net
@ 2006-07-11  8:29 ` bangerth at dealii dot org
  2008-03-02 10:57 ` truedfx at gentoo dot org
  2009-12-08 21:07 ` redi at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2006-07-11  8:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bangerth at dealii dot org  2006-07-11 08:29 -------
As usual, a reduced (or at least smaller than 51,000 lines) testcase would be
supremely helpful...

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org


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


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

* [Bug c++/28330] finds wrong template overload; peculiar diagnostic
  2006-07-10 20:11 [Bug c++/28330] New: finds wrong template overload; peculiar diagnostic igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2006-07-11  8:29 ` bangerth at dealii dot org
@ 2008-03-02 10:57 ` truedfx at gentoo dot org
  2009-12-08 21:07 ` redi at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: truedfx at gentoo dot org @ 2008-03-02 10:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from truedfx at gentoo dot org  2008-03-02 10:57 -------
I only came across this bug looking for something else, but anyway, here's a
reduced testcase:

template <typename T>
class ring {};

template <typename T>
ring<T> &operator<<(ring<T>&, T *);

class base {};
class derived : public base {};

void f() {
  ring<base> r;
  derived *d;
  r << d;
}

I believe this code is invalid. The template argument can't be deduced, and
you'd need something like

template <typename T>
class ring {};

template <typename T>
struct non_deducible { typename T type; };

template <typename T>
ring<T> &operator<<(ring<T>&, typename non_deducible<T>::type *);

so that only the first argument is considered when choosing which T to use.

Or, more simply, make operator<< a member function.


-- 

truedfx at gentoo dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |truedfx at gentoo dot org


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


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

* [Bug c++/28330] finds wrong template overload; peculiar diagnostic
  2006-07-10 20:11 [Bug c++/28330] New: finds wrong template overload; peculiar diagnostic igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2008-03-02 10:57 ` truedfx at gentoo dot org
@ 2009-12-08 21:07 ` redi at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu dot org @ 2009-12-08 21:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from redi at gcc dot gnu dot org  2009-12-08 21:06 -------
Assuming that's an accurate reduction of the original code, comment 4 is
correct.  I didn't look at the preprocessed source, it includes Boost code that
will be very specific to the GCC 4.0.2 version it was compiled with and so
useless with any other version of GCC


-- 

redi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2009-12-08 21:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-10 20:11 [Bug c++/28330] New: finds wrong template overload; peculiar diagnostic igodard at pacbell dot net
2006-07-10 20:11 ` [Bug c++/28330] " igodard at pacbell dot net
2006-07-10 20:12 ` igodard at pacbell dot net
2006-07-11  8:29 ` bangerth at dealii dot org
2008-03-02 10:57 ` truedfx at gentoo dot org
2009-12-08 21:07 ` redi 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).