Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: 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 On a VAX, the following program dies horribly under version 1.0: ------------------------------------------------------------------------ #include 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