public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands
@ 2005-09-13 20:22 janis at gcc dot gnu dot org
  2005-09-13 20:26 ` [Bug libstdc++/23871] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: janis at gcc dot gnu dot org @ 2005-09-13 20:22 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2989 bytes --]

This testcase from an IBM internal user:
                                                                                
  #include <iostream>
  class mytest {
  public:
    mytest (int);
    unsigned char operator|| (const mytest&) const;
    friend unsigned char operator|| (const int&, const mytest&);
  };
  inline unsigned char operator|| (const int& lhs, const mytest& rhs)
  {
    std::cout << 1 << std::endl;
    return (mytest)lhs || rhs;
  }
                                                                                
fails with FSF 4.0 releases and the current 4.0 branch with:
                                                                                
elm3b11% /opt/gcc-nightly/4.0/bin/g++ -c bug.cc
/home/gcc-nightly/4.0-20050913/bin/../lib/gcc/powerpc64-linux/4.0.2/../../../../include/c++/4.0.2/ostream:
In member function ‘std::basic_ostream<_CharT, _Traits>&
std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char,
_Traits = std::char_traits<char>]’:
bug.cc:10:   instantiated from here
/home/gcc-nightly/4.0-20050913/bin/../lib/gcc/powerpc64-linux/4.0.2/../../../../include/c++/4.0.2/ostream:194:
error: ISO C++ says that these are ambiguous, even though the worst conversion
for the first is better than the worst conversion
for the second:
/home/gcc-nightly/4.0-20050913/bin/../lib/gcc/powerpc64-linux/4.0.2/../../../../include/c++/4.0.2/ostream:194:
note: candidate 1: operator||(bool, bool) <built-in>
bug.cc:8: note: candidate 2: unsigned char operator||(const int&, const mytest&)
                                                                               
This is due to code for operator<<(int) in std_ostream.h that uses || on
integral (not bool) operands, leading to the ambiguity between the built-in
|| operator and one defined in the testcase.  It is a regression because
versions earlier than 4.0 failed to report the error.
                                                                                
The testcase passes on mainline starting with this patch from Paolo Carlini:
                                                                                
  http://gcc.gnu.org/ml/gcc-cvs/2005-07/msg00424.html
  http://gcc.gnu.org/ml/gcc-patches/2005-07/msg00726.html
                                                                                
I'm currently testing this part of that patch with the 4.0 branch:

        * include/std/std_ostream.h (operator<<(short), operator<<(int)):
        Adjust logic, as per the letter of the resolution of DR117 [WP].

-- 
           Summary: iostream operator<<(int) uses || on integral operands
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janis at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug libstdc++/23871] [4.0 Regression] iostream operator<<(int) uses || on integral operands
  2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
@ 2005-09-13 20:26 ` pinskia at gcc dot gnu dot org
  2005-09-13 22:28 ` pcarlini at suse dot de
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-13 20:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-13 20:26 -------
Confirmed, a regression from 3.4.0.  Just a note, 4.0 branch is frozen right now.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
      Known to fail|                            |4.0.0
      Known to work|                            |3.4.0 4.1.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-09-13 20:26:41
               date|                            |
            Summary|iostream operator<<(int)    |[4.0 Regression] iostream
                   |uses || on integral operands|operator<<(int) uses || on
                   |                            |integral operands
   Target Milestone|---                         |4.0.2


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


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

* [Bug libstdc++/23871] [4.0 Regression] iostream operator<<(int) uses || on integral operands
  2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
  2005-09-13 20:26 ` [Bug libstdc++/23871] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-09-13 22:28 ` pcarlini at suse dot de
  2005-09-16 20:18 ` cvs-commit at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2005-09-13 22:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-09-13 22:27 -------
Yes, for 4.0.3 backporting only those bits would make sense. Thanks Janis for
testing.

-- 


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


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

* [Bug libstdc++/23871] [4.0 Regression] iostream operator<<(int) uses || on integral operands
  2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
  2005-09-13 20:26 ` [Bug libstdc++/23871] [4.0 Regression] " pinskia at gcc dot gnu dot org
  2005-09-13 22:28 ` pcarlini at suse dot de
@ 2005-09-16 20:18 ` cvs-commit at gcc dot gnu dot org
  2005-09-27 16:08 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-09-16 20:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-09-16 20:18 -------
Subject: Bug 23871

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	janis@gcc.gnu.org	2005-09-16 20:18:11

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/std: std_ostream.h 
	libstdc++-v3/include/bits: ostream.tcc 
Added files:
	libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char: 
	                                                                      7.cc 
	                                                                      23871.cc 
	libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t: 
	                                                                         7.cc 

Log message:
	PR libstdc++/23871
	
	Backport:
	2005-07-11  Paolo Carlini  <pcarlini@suse.de>
	* include/std/std_ostream.h (operator<<(short), operator<<(int)):
	Adjust logic, as per the letter of the resolution of DR117 [WP].
	* testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc: New.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc: New.
	
	* include/bits/ostream.tcc (operator<<(long), operator<<(long long)):
	Adjust logic.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/char/23871.cc:
	New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.2917.2.82&r2=1.2917.2.83
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_ostream.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.16&r2=1.16.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/ostream.tcc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.54&r2=1.54.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.2.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/23871.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.2.4.1



-- 


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


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

* [Bug libstdc++/23871] [4.0 Regression] iostream operator<<(int) uses || on integral operands
  2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-09-16 20:18 ` cvs-commit at gcc dot gnu dot org
@ 2005-09-27 16:08 ` mmitchel at gcc dot gnu dot org
  2005-09-27 18:16 ` janis187 at us dot ibm dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:08 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


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


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

* [Bug libstdc++/23871] [4.0 Regression] iostream operator<<(int) uses || on integral operands
  2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-09-27 16:08 ` mmitchel at gcc dot gnu dot org
@ 2005-09-27 18:16 ` janis187 at us dot ibm dot com
  2005-09-28  0:28 ` pinskia at gcc dot gnu dot org
  2005-09-28  0:29 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: janis187 at us dot ibm dot com @ 2005-09-27 18:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From janis187 at us dot ibm dot com  2005-09-27 17:18 -------
This is fixed in 4.0.2.  I forgot and checked it into the branch before RC2;
Paolo said it was safe and to leave it in unless Mark said to yank it out.

I've messed up my Bugzilla settings and can't change the PR to "fixed".

-- 


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


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

* [Bug libstdc++/23871] [4.0 Regression] iostream operator<<(int) uses || on integral operands
  2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-09-27 18:16 ` janis187 at us dot ibm dot com
@ 2005-09-28  0:28 ` pinskia at gcc dot gnu dot org
  2005-09-28  0:29 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-28  0:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-28 00:28 -------
Fixed for 4.0.2 as requested by Janis.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.3                       |4.0.2


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


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

* [Bug libstdc++/23871] [4.0 Regression] iostream operator<<(int) uses || on integral operands
  2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-09-28  0:28 ` pinskia at gcc dot gnu dot org
@ 2005-09-28  0:29 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-28  0:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-28 00:28 -------
Fixed for 4.0.2 as requested by Janis.

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


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


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

end of thread, other threads:[~2005-09-28  0:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-13 20:22 [Bug libstdc++/23871] New: iostream operator<<(int) uses || on integral operands janis at gcc dot gnu dot org
2005-09-13 20:26 ` [Bug libstdc++/23871] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-09-13 22:28 ` pcarlini at suse dot de
2005-09-16 20:18 ` cvs-commit at gcc dot gnu dot org
2005-09-27 16:08 ` mmitchel at gcc dot gnu dot org
2005-09-27 18:16 ` janis187 at us dot ibm dot com
2005-09-28  0:28 ` pinskia at gcc dot gnu dot org
2005-09-28  0:29 ` 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).