public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26037]  New: no match for 'operator<<'
@ 2006-01-30 17:26 tony dot luu at baesystems dot com
  2006-01-30 17:31 ` [Bug c++/26037] " tony dot luu at baesystems dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: tony dot luu at baesystems dot com @ 2006-01-30 17:26 UTC (permalink / raw)
  To: gcc-bugs

The following stripped-down code fails to compile in g++3.4.5 (compiles fine
with other compilers).

// CODE SNIPPET.
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

namespace MyNameSpace {
   struct Point
   {
      double x;
      double y;
      double z;
   };
} // namespace

std::ostream&
operator<< (std::ostream& os, const MyNameSpace::Point& src)
{
   return os;
}

int
main (void)
{
   std::vector<MyNameSpace::Point> polygons;

   copy (polygons.begin (), polygons.end (),
         std::ostream_iterator<MyNameSpace::Point> (std::cout, " ")); // ERROR

   return 0;
}

and g++ generates the following error message:

error: no match for 'operator<<' in
'*((std::ostream_iterator<MyNameSpace::Point, char, std::char_traits<char>
>*)this)->std::ostream_iterator<MyNameSpace::Point, char,
std::char_traits<char> >::_M_stream << __value'

Note: the code compiles if I removed the namespace.


-- 
           Summary: no match for 'operator<<'
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tony dot luu at baesystems dot com


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


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

* [Bug c++/26037] no match for 'operator<<'
  2006-01-30 17:26 [Bug c++/26037] New: no match for 'operator<<' tony dot luu at baesystems dot com
@ 2006-01-30 17:31 ` tony dot luu at baesystems dot com
  2006-01-30 18:00 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: tony dot luu at baesystems dot com @ 2006-01-30 17:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tony dot luu at baesystems dot com  2006-01-30 17:31 -------
Created an attachment (id=10763)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10763&action=view)
test code

fail to compile with g++ 3.4.5.
compiles ok with other compilers (SGI, SUN).


-- 


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


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

* [Bug c++/26037] no match for 'operator<<'
  2006-01-30 17:26 [Bug c++/26037] New: no match for 'operator<<' tony dot luu at baesystems dot com
  2006-01-30 17:31 ` [Bug c++/26037] " tony dot luu at baesystems dot com
@ 2006-01-30 18:00 ` pcarlini at suse dot de
  2006-01-30 18:03 ` pinskia at gcc dot gnu dot org
  2006-01-30 18:14 ` gdr at integrable-solutions dot net
  3 siblings, 0 replies; 5+ messages in thread
From: pcarlini at suse dot de @ 2006-01-30 18:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pcarlini at suse dot de  2006-01-30 18:00 -------
Not a bug, this is how name lookup works. And any conforming, up to date,
compiler behaves in the same way. You can fix your code moving operator<<
inside namespace MyNameSpace.

I'm sure there are many duplicates, I'm going to link C++/7049 (see Comment #6)

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


-- 

pcarlini at suse dot de changed:

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


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


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

* [Bug c++/26037] no match for 'operator<<'
  2006-01-30 17:26 [Bug c++/26037] New: no match for 'operator<<' tony dot luu at baesystems dot com
  2006-01-30 17:31 ` [Bug c++/26037] " tony dot luu at baesystems dot com
  2006-01-30 18:00 ` pcarlini at suse dot de
@ 2006-01-30 18:03 ` pinskia at gcc dot gnu dot org
  2006-01-30 18:14 ` gdr at integrable-solutions dot net
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-30 18:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-01-30 18:03 -------
I should note this is called argument dependent lookup (or ADL, there is
another name for it after a person but he no longer wants to be associated with
this).


-- 


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


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

* [Bug c++/26037] no match for 'operator<<'
  2006-01-30 17:26 [Bug c++/26037] New: no match for 'operator<<' tony dot luu at baesystems dot com
                   ` (2 preceding siblings ...)
  2006-01-30 18:03 ` pinskia at gcc dot gnu dot org
@ 2006-01-30 18:14 ` gdr at integrable-solutions dot net
  3 siblings, 0 replies; 5+ messages in thread
From: gdr at integrable-solutions dot net @ 2006-01-30 18:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from gdr at integrable-solutions dot net  2006-01-30 18:14 -------
Subject: Re:  no match for 'operator<<'

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| I should note this is called argument dependent lookup (or ADL, there is
| another name for it after a person but he no longer wants to be
| associated with this).

yup.

The printing is a bit ugly though.  Should be fixed (not the PR, the
printing). 

-- Gaby


-- 


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


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

end of thread, other threads:[~2006-01-30 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-30 17:26 [Bug c++/26037] New: no match for 'operator<<' tony dot luu at baesystems dot com
2006-01-30 17:31 ` [Bug c++/26037] " tony dot luu at baesystems dot com
2006-01-30 18:00 ` pcarlini at suse dot de
2006-01-30 18:03 ` pinskia at gcc dot gnu dot org
2006-01-30 18:14 ` gdr at integrable-solutions dot net

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).