Article View: gnu.g++.lib.bug
Article #95bug in Integer.cc + fix
From: Ron Sommeling
Date: Thu, 16 Apr 1992 11:18
Date: Thu, 16 Apr 1992 11:18
45 lines
1601 bytes
1601 bytes
There is a bug in the function
istream& operator >> (istream& s, Integer& y)
of the GNU g++ library libg++-2.0.
The following program gives a segmentation fault when fed with the input
0 0
(SPARCstation 1, SunOS 4.1.1, g++ 2.1, libg++-2.0)
#include <iostream.h>
#include <Integer.h>
main() {
Integer a, b;
cin >> a >> b;
cout << "a = " << a << ", b = " << b << endl;
}
Below is a context diff to fix the bug.
Ron Sommeling <Ron.Sommeling@cwi.nl>
*** Integer.cc.orig Fri Mar 6 08:57:52 1992
--- Integer.cc Thu Apr 16 13:10:50 1992
***************
*** 2326,2335 ****
else
break;
}
! else if (!know_base & !got_one && ch == '0')
! base = 8;
! else if (!know_base & !got_one && base == 8 && (ch == 'X' || ch == 'x'))
! base = 16;
else if (base == 8)
{
if (ch >= '0' && ch <= '7')
--- 2326,2337 ----
else
break;
}
! else if (!know_base & !got_one && ch == '0') {
! base = 8; got_one = 2;
! }
! else if (gotone == 2 && (ch == 'X' || ch == 'x')) {
! base = 16; got_one = 0; know_base = 1;
! }
else if (base == 8)
{
if (ch >= '0' && ch <= '7')
Technical Details
Message-ID:
<5863@charon.cwi.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cwi.NL!Ron.SommelingShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.lib.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cwi.NL!Ron.Sommeling From: Ron.Sommeling@cwi.NL (Ron Sommeling) Subject: bug in Integer.cc + fix Message-ID: <5863@charon.cwi.nl> Sender: gnulists@ai.mit.edu Organization: CWI, Amsterdam Distribution: gnu Date: Thu, 16 Apr 1992 11:18:55 GMT Approved: bug-lib-g++@prep.ai.mit.edu Lines: 46