Thread View: gnu.g++.lib.bug
1 messages
1 total messages
Started by Ron Sommeling
Thu, 16 Apr 1992 11:18
bug in Integer.cc + fix
Author: 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')
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads