Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!garfield.columbia.edu!eppstein From: eppstein@garfield.columbia.edu (David Eppstein) Newsgroups: comp.lang.c++,comp.lang.c Subject: bug re unsigned to signed conversion? Message-ID: <4626@columbia.UUCP> Date: Sun, 24-May-87 15:39:29 EDT Article-I.D.: columbia.4626 Posted: Sun May 24 15:39:29 1987 Date-Received: Sun, 24-May-87 21:44:37 EDT Sender: nobody@columbia.UUCP Organization: Columbia University CS Department Lines: 24 Xref: mnetor comp.lang.c++:288 comp.lang.c:2232 The following program prints both messages. I would expect it to print neither, but at least the second message shouldn't happen. The generated C code for the two lines is essentially identical; no doubt the second line and probably the first should have generated a cast to int. This is on a Vax running 4.3; I don't know what version C++. It occurred in a real example and took me much grief to track down. I'm not convinced the C compiler is correct, which is why I'm also cross posting to comp.lang.c. ------------ #include int a = -1; unsigned b = 2; inline int conv() { return b; } main() { if (a > b) cout << "(int) -1 > (unsigned) 2 ???\n"; if (a > conv()) cout << "(int) -1 > (int) (unsigned) 2 ????????\n"; } -- David Eppstein, eppstein@cs.columbia.edu, Columbia U. Computer Science Dept.