Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mtuxo!mtune!rutgers!bellcore!faline!ulysses!allegra!alice!bs From: bs@alice.UUCP Newsgroups: comp.lang.c++ Subject: Re: BUG Message-ID: <7329@alice.UUCP> Date: Wed, 30-Sep-87 20:57:24 EDT Article-I.D.: alice.7329 Posted: Wed Sep 30 20:57:24 1987 Date-Received: Sat, 3-Oct-87 09:20:59 EDT References: <1131@water.waterloo.edu> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 51 Summary: FIX and workaround # From cbosgd!water.UUCP!pabuhr Mon Sep 28 22:05:29 1987 # Organization: U. of Waterloo, Ontario # # /* # It took me 4 hours to locate this problem in a large program. # If you look at the C++ code generated for the inline procedure # `identity', you will notice that it has been optimized into the # same single constant! I need a drink. I guess I owe you one. Sorry. Thank you for finding that one. Have a look at my test::id() function. It doesn't trigger that bug. # */ # # class test { # public: # inline int identity(test *); int id(test *h) { return this==h; } # }; # # inline int test::identity(test *h) { # if (this != h) { # return(0); # } else { # return(1); # } # }; # # main() { # test a, b; # # a.identity(&a); # a.identity(&b); a.id(&a); a.id(&b); # } You can fix that bug by going into expr::eval() in expr2.c and adding one statement: int i1 = (e1) ? e1->eval() : 0; // after int i2 = (e2) ? e2->eval() : 0; // this if (binary_val && i1==9999 && i2==9999) { // add this Neval = ""; // add this return 1; // add this } // add this };