public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/57213] New: failed formatted input overwrites output value
@ 2013-05-08 15:50 sbn at tbricks dot com
  2013-05-08 16:01 ` [Bug libstdc++/57213] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: sbn at tbricks dot com @ 2013-05-08 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 57213
           Summary: failed formatted input overwrites output value
    Classification: Unclassified
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sbn@tbricks.com


Hello!

Here is a small test:

#include <sstream>
#include <iostream>

int main()
{
    std::istringstream iss("-a");
    unsigned i = 12345;
    iss >> i;
    std::cout << i << std::endl;
    return 0;
}

When building it with latest GCC 4.8.1 (svn rev. 198709) on Solaris 10 I got
the following output:

$ /opt/gcc-4.8/bin/g++ -v -std=c++03 a.cpp
Using built-in specs.
COLLECT_GCC=/opt/gcc-4.8/bin/g++
COLLECT_LTO_WRAPPER=/opt/gcc-4.8/libexec/gcc/i386-pc-solaris2.10/4.8.1/lto-wrapper
Target: i386-pc-solaris2.10
Configured with: /export/home/sbn/src/gcc-4.8/configure --prefix=/opt/gcc-4.8
--enable-languages=c,c++ --with-ld=/usr/ccs/bin/ld --without-gnu-ld
--with-gnu-as --with-as=/opt/csw/bin/gas
Thread model: posix
gcc version 4.8.1 20130508 (prerelease) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-std=c++98' '-shared-libgcc' '-mtune=generic'
'-march=pentium4'
 /opt/gcc-4.8/libexec/gcc/i386-pc-solaris2.10/4.8.1/cc1plus -quiet -v a.cpp
-quiet -dumpbase a.cpp -mtune=generic -march=pentium4 -auxbase a -std=c++98
-version -o /var/tmp//ccqRQJAe.s
GNU C++ (GCC) version 4.8.1 20130508 (prerelease) (i386-pc-solaris2.10)
        compiled by GNU C version 4.8.1 20130508 (prerelease), GMP version
4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/../../../../i386-pc-solaris2.10/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/../../../../include/c++/4.8.1

/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/../../../../include/c++/4.8.1/i386-pc-solaris2.10

/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/../../../../include/c++/4.8.1/backward
 /opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/include
 /opt/gcc-4.8/include
 /opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.8.1 20130508 (prerelease) (i386-pc-solaris2.10)
        compiled by GNU C version 4.8.1 20130508 (prerelease), GMP version
4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c518101980ab073fe5c4f884a6f42b1b
COLLECT_GCC_OPTIONS='-v' '-std=c++98' '-shared-libgcc' '-mtune=generic'
'-march=pentium4'
 /opt/csw/bin/gas -v -V -Qy -s --32 -o /var/tmp//ccOebkCA.o
/var/tmp//ccqRQJAe.s
GNU assembler version 2.23.1 (i386-pc-solaris2.10) using BFD version (GNU
Binutils) 2.23.1
COMPILER_PATH=/opt/gcc-4.8/libexec/gcc/i386-pc-solaris2.10/4.8.1/:/opt/gcc-4.8/libexec/gcc/i386-pc-solaris2.10/4.8.1/:/opt/gcc-4.8/libexec/gcc/i386-pc-solaris2.10/:/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/:/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/:/usr/ccs/bin/
LIBRARY_PATH=/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/:/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-std=c++98' '-shared-libgcc' '-mtune=generic'
'-march=pentium4'
 /opt/gcc-4.8/libexec/gcc/i386-pc-solaris2.10/4.8.1/collect2 -V -Y
P,/usr/ccs/lib:/lib:/usr/lib -Qy /usr/lib/crt1.o /usr/lib/crti.o
/usr/lib/values-Xa.o /opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/crtbegin.o
-L/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1
-L/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/../../.. /var/tmp//ccOebkCA.o
-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/opt/gcc-4.8/lib/gcc/i386-pc-solaris2.10/4.8.1/crtend.o /usr/lib/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.1509
$ LD_LIBRARY_PATH=/opt/gcc-4.8/lib ./a.out 
0
$ uname -a
SunOS node8 5.10 Generic_147441-16 i86pc i386 i86pc

But I expect it to return 12345 (and it's in fact the case if I use GCC 3.4.3
shipped with Solaris 10 SFW)

In C++ standard (C++03) I can see 22.2.2.1.2p1 [lib.facet.num.get.virtuals]:
"If an error occurs, val is unchanged; otherwise it is set to the resulting
value."


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

* [Bug libstdc++/57213] failed formatted input overwrites output value
  2013-05-08 15:50 [Bug libstdc++/57213] New: failed formatted input overwrites output value sbn at tbricks dot com
@ 2013-05-08 16:01 ` redi at gcc dot gnu.org
  2013-05-09  7:34 ` sbn at tbricks dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-08 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-05-08 16:01:01 UTC ---
(In reply to comment #0)
> In C++ standard (C++03) I can see 22.2.2.1.2p1 [lib.facet.num.get.virtuals]:
> "If an error occurs, val is unchanged; otherwise it is set to the resulting
> value."

That wording was removed by DR 696
http://cplusplus.github.io/LWG/lwg-defects.html#696


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

* [Bug libstdc++/57213] failed formatted input overwrites output value
  2013-05-08 15:50 [Bug libstdc++/57213] New: failed formatted input overwrites output value sbn at tbricks dot com
  2013-05-08 16:01 ` [Bug libstdc++/57213] " redi at gcc dot gnu.org
@ 2013-05-09  7:34 ` sbn at tbricks dot com
  2013-05-09  8:06 ` redi at gcc dot gnu.org
  2013-05-09  8:12 ` sbn at tbricks dot com
  3 siblings, 0 replies; 5+ messages in thread
From: sbn at tbricks dot com @ 2013-05-09  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

Dmitri Shubin <sbn at tbricks dot com> changed:

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

--- Comment #3 from Dmitri Shubin <sbn at tbricks dot com> 2013-05-09 07:34:12 UTC ---
Yes, I know that the wording was changed in C++11, but I explicitly want C++03
compatibility.
Or this DR affects C++03 (and C++98) also?


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

* [Bug libstdc++/57213] failed formatted input overwrites output value
  2013-05-08 15:50 [Bug libstdc++/57213] New: failed formatted input overwrites output value sbn at tbricks dot com
  2013-05-08 16:01 ` [Bug libstdc++/57213] " redi at gcc dot gnu.org
  2013-05-09  7:34 ` sbn at tbricks dot com
@ 2013-05-09  8:06 ` redi at gcc dot gnu.org
  2013-05-09  8:12 ` sbn at tbricks dot com
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-09  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-05-09 08:06:10 UTC ---
(In reply to comment #3)
> Or this DR affects C++03 (and C++98) also?

Yes, it's not a new feature of C++11, it's a *defect* in C++03 so we fixed it
according to the committee's agreed resolution.  The old specification was
broken.

This is similar to fixing bugs in libstdc++, we don't keep the old defective
behaviour around as well, we fix it.


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

* [Bug libstdc++/57213] failed formatted input overwrites output value
  2013-05-08 15:50 [Bug libstdc++/57213] New: failed formatted input overwrites output value sbn at tbricks dot com
                   ` (2 preceding siblings ...)
  2013-05-09  8:06 ` redi at gcc dot gnu.org
@ 2013-05-09  8:12 ` sbn at tbricks dot com
  3 siblings, 0 replies; 5+ messages in thread
From: sbn at tbricks dot com @ 2013-05-09  8:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Dmitri Shubin <sbn at tbricks dot com> 2013-05-09 08:12:25 UTC ---
(In reply to comment #4)

> This is similar to fixing bugs in libstdc++, we don't keep the old defective
> behaviour around as well, we fix it.

But this fix breaks backward compatibility.
I have perfectly working program written according to C++98 standard and
suddenly it stopped working.
This is really really strange.
Probably I should file a bug against vendor of my distro (RedHat)


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

end of thread, other threads:[~2013-05-09  8:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-08 15:50 [Bug libstdc++/57213] New: failed formatted input overwrites output value sbn at tbricks dot com
2013-05-08 16:01 ` [Bug libstdc++/57213] " redi at gcc dot gnu.org
2013-05-09  7:34 ` sbn at tbricks dot com
2013-05-09  8:06 ` redi at gcc dot gnu.org
2013-05-09  8:12 ` sbn at tbricks dot com

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