public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8279: REGRESSION: failure to find a matching function in ostream_iterator expansion
@ 2002-10-21  9:06 Wolfgang Bangerth
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Bangerth @ 2002-10-21  9:06 UTC (permalink / raw)
  To: paolo; +Cc: gcc-prs

The following reply was made to PR c++/8279; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>, <jbuck@synopsys.com>,
   <paolo@gcc.gnu.org>
Cc:  
Subject: Re: c++/8279: REGRESSION: failure to find a matching function in
 ostream_iterator expansion
Date: Mon, 21 Oct 2002 11:04:09 -0500 (CDT)

 The testcase fails for a relatively simple reason: copying to an 
 ostream_iterator invokes ostream_iterator::operator=, which here looks 
 like this:
       ostream_iterator& 
       operator=(const _Tp& __value) 
       { 
 	*_M_stream << __value;
 	//...
 	return *this;
       }
 _M_stream is of type std::ostream, and __value of type _Tp=std::pair. So 
 the compiler looks for an operator
       std::ostream << std::pair
 
 Since the declaration of this class is in namespace std, in looks for this 
 operator in namespace std. Since both types are in namespace std, Koenig 
 lookup also does not bring in additional namespaces. It will thus not find 
 the globally declared operator of the test case.
 
 This also explains, why it is not compilable with icc6, as well as that it 
 compiled with gcc2.95, since that did not know about namespace std.
 
 I don't think there is a simple solution to work around this, short of 
 putting the respective operator in namespace std.
 
 At least, I believe the compiler is right to reject the code, and that 
 this is not a bug.
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 


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

* Re: c++/8279: REGRESSION: failure to find a matching function in ostream_iterator expansion
@ 2002-10-22 11:01 jbuck
  0 siblings, 0 replies; 5+ messages in thread
From: jbuck @ 2002-10-22 11:01 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, jbuck, paolo

Synopsis: REGRESSION: failure to find a matching function in ostream_iterator expansion

State-Changed-From-To: feedback->closed
State-Changed-By: jbuck
State-Changed-When: Tue Oct 22 11:01:21 2002
State-Changed-Why:
    The conclusion of the language experts is that this is not
    a bug.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8279


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

* Re: c++/8279: REGRESSION: failure to find a matching function in ostream_iterator expansion
@ 2002-10-21  9:36 Paolo Carlini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Carlini @ 2002-10-21  9:36 UTC (permalink / raw)
  To: paolo; +Cc: gcc-prs

The following reply was made to PR c++/8279; it has been noted by GNATS.

From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org,  gcc-prs@gcc.gnu.org,  jbuck@synopsys.com, 
 gcc-bugs@gcc.gnu.org,  paolo@gcc.gnu.org
Cc:  
Subject: Re: c++/8279: REGRESSION: failure to find a matching function in
 ostream_iterator expansion
Date: Mon, 21 Oct 2002 18:31:47 +0200

 Hi everyone,
 
 I'm tempted to agree with Wolfgang...
 
 Anyway, a quick couple of additional data points: both the widespread 
 EDG-based compilers agree with recent GCCs on this matter: Icc and 
 Comeau. Also, same behavior for Metrowerks CW8.2.
 
 Ciao, Paolo.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8279
 


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

* Re: c++/8279: REGRESSION: failure to find a matching function in ostream_iterator expansion
@ 2002-10-19  3:58 paolo
  0 siblings, 0 replies; 5+ messages in thread
From: paolo @ 2002-10-19  3:58 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, jbuck, nobody, paolo

Synopsis: REGRESSION: failure to find a matching function in ostream_iterator expansion

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sat Oct 19 03:58:15 2002
Responsible-Changed-Why:
    .
State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Sat Oct 19 03:58:15 2002
State-Changed-Why:
    The testcase doesn't compile with 3.0.4/3.1.1/Icc6 either.
    I'm not a language lawyer but what about putting the
    operator<< inside namespace std:: ??
    The following works for me (and all the compilers above):
    #include <iostream>
    #include <algorithm>
    #include <iterator>
    #include <vector>
    
    typedef std::pair<int,int> Pairtype;
    
    namespace std {
      inline std::ostream& operator<<(std::ostream& o, const Pairtype& a) {
        o << a.first << ": " << a.second;
        return o;
      }
    }
    
    int main()
    {
      std::vector<Pairtype> data;
    
      std::copy(data.begin(), data.end(),
    	    std::ostream_iterator<Pairtype>(std::cout, "\n"));
    }

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8279


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

* c++/8279: REGRESSION: failure to find a matching function in ostream_iterator expansion
@ 2002-10-18 13:56 jbuck
  0 siblings, 0 replies; 5+ messages in thread
From: jbuck @ 2002-10-18 13:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8279
>Category:       c++
>Synopsis:       REGRESSION: failure to find a matching function in ostream_iterator expansion
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 18 13:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Joe Buck
>Release:        gcc-3.2
>Organization:
>Environment:
both linux (red hat 7.2) and solaris (sparc 2.7)
>Description:
The attached program compiles and runs correctly under
gcc 2.95.2, but fails to compile under gcc 3.2 (including
the release branch as of 17 Oct).  The compiler complains
that it cannot find a compatible operator<< while expanding
the ostream_iterator template, even though an exact match
is present.  Defining HIDE_BUG reveals that the compiler is
perfectly capable of finding the operator<< and using it
when a loop, rather than std::copy to the ostream_iterator,
is used
>How-To-Repeat:
Do
gcc -c map_test.cpp
for comparison, try
gcc -c -DHIDE_BUG map_test.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="map_test.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="map_test.cpp"

I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGht
PgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDx2ZWN0b3I+Cgp0
eXBlZGVmIHN0ZDo6bWFwPHN0ZDo6c3RyaW5nLHVuc2lnbmVkPiBNYXB0eXBlOwp0eXBlZGVmIHN0
ZDo6cGFpcjxzdGQ6OnN0cmluZyx1bnNpZ25lZD4gUGFpcnR5cGU7CgpjbGFzcyBPcmRlcmluZyB7
CnB1YmxpYzoKICBib29sIG9wZXJhdG9yKCkoY29uc3QgUGFpcnR5cGUmIGEsIGNvbnN0IFBhaXJ0
eXBlJiBiKSBjb25zdCB7CiAgICBpZiAoYS5zZWNvbmQgIT0gYi5zZWNvbmQpCiAgICAgIHJldHVy
biBhLnNlY29uZCA8IGIuc2Vjb25kOwogICAgcmV0dXJuIGEuZmlyc3QgPCBiLmZpcnN0OwogIH0K
fTsKCmlubGluZSBzdGQ6Om9zdHJlYW0mIG9wZXJhdG9yPDwoc3RkOjpvc3RyZWFtJiBvLCBjb25z
dCBQYWlydHlwZSYgYSkgewogIG8gPDwgYS5maXJzdCA8PCAiOiAiIDw8IGEuc2Vjb25kOwogIHJl
dHVybiBvOwp9Cgp2b2lkIGZvbyhjb25zdCBQYWlydHlwZSYgYSkgewogIHN0ZDo6Y291dCA8PCBh
IDw8IHN0ZDo6ZW5kbDsKfQoKaW50IG1haW4oKQp7CiAgTWFwdHlwZSB3b3JkX2NvdW50OwogIHN0
ZDo6c3RyaW5nIHdvcmQ7CiAgd2hpbGUgKHN0ZDo6Y2luID4+IHdvcmQpCiAgICB3b3JkX2NvdW50
W3dvcmRdICs9IDE7CiAgc3RkOjp2ZWN0b3I8UGFpcnR5cGU+IGRhdGEod29yZF9jb3VudC5iZWdp
bigpLCB3b3JkX2NvdW50LmVuZCgpKTsKICBzdGQ6OnNvcnQoZGF0YS5iZWdpbigpLCBkYXRhLmVu
ZCgpLCBPcmRlcmluZygpKTsKI2lmZGVmIEhJREVfQlVHCiAgZm9yIChzdGQ6OnZlY3RvcjxQYWly
dHlwZT46OmNvbnN0X2l0ZXJhdG9yIHAgPSBkYXRhLmJlZ2luKCk7IHAgIT0gZGF0YS5lbmQoKTsg
KytwKQogICAgc3RkOjpjb3V0IDw8ICgqcCkgPDwgc3RkOjplbmRsOwojZWxzZQogIHN0ZDo6Y29w
eShkYXRhLmJlZ2luKCksIGRhdGEuZW5kKCksCgkgICAgc3RkOjpvc3RyZWFtX2l0ZXJhdG9yPFBh
aXJ0eXBlPihzdGQ6OmNvdXQsICJcbiIpKTsKI2VuZGlmCn0KCg==


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

end of thread, other threads:[~2002-10-22 18:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-21  9:06 c++/8279: REGRESSION: failure to find a matching function in ostream_iterator expansion Wolfgang Bangerth
  -- strict thread matches above, loose matches on Subject: below --
2002-10-22 11:01 jbuck
2002-10-21  9:36 Paolo Carlini
2002-10-19  3:58 paolo
2002-10-18 13:56 jbuck

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