Article View: net.lang.c++
Article #328Hex bombs on negative argument
From: kenny
Date: Thu, 25 Sep 1986 18:45
Date: Thu, 25 Sep 1986 18:45
19 lines
1309 bytes
1309 bytes
On a VAX, the following program dies horribly under version 1.0:
------------------------------------------------------------------------
#include <stream.h>
main (int argc, char *argv[]) {
int x = -1;
cout << hex (x, 8) << "\n";
}
------------------------------------------------------------------------
The problem is that in ``out.c'' the parameter ``i'' to the ``hex''
function is declared as long, but the conversion loop is a `` do { ...
} while (i>>=4);'' this is an endless loop for negative numbers.
Kevin Kenny UUCP: {ihnp4,pur-ee,convex}!uiucdcs!kenny
Department of Computer Science ARPA: kenny@B.CS.UIUC.EDU (kenny@UIUC.ARPA)
University of Illinois CSNET: kenny@UIUC.CSNET
1304 W. Springfield Ave.
Urbana, Illinois, 61801 Voice: (217) 333-7980
Technical Details
Message-ID:
<154000003@uiucdcsb>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!inuxc!pur-ee!uiucdcs!uiucdcsb!kennyShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!inuxc!pur-ee!uiucdcs!uiucdcsb!kenny From: kenny@uiucdcsb.cs.uiuc.edu Newsgroups: net.lang.c++ Subject: Hex bombs on negative argument Message-ID: <154000003@uiucdcsb> Date: Thu, 25-Sep-86 14:45:00 EDT Article-I.D.: uiucdcsb.154000003 Posted: Thu Sep 25 14:45:00 1986 Date-Received: Tue, 30-Sep-86 01:46:19 EDT Lines: 19 Nf-ID: #N:uiucdcsb:154000003:000:765 Nf-From: uiucdcsb.cs.uiuc.edu!kenny Sep 25 13:45:00 1986