Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!munnari.oz.au!bruce!monu0.cc.monash.edu.au!vaxc.cc.monash.edu.au!apm233m From: apm233m@vaxc.cc.monash.edu.au Newsgroups: comp.lang.c++ Subject: Bug fix for Turbo C++ v1.0 ? Message-ID: <1991Jun26.155459.86966@vaxc.cc.monash.edu.au> Date: 26 Jun 91 05:54:59 GMT Organization: Computer Centre, Monash University, Australia Lines: 32 My question is: is there a patch for Turbo C++ v1.0 to fix the following code generation bug? The bug concerns the code generated for a right shift of longs. The following short program demonstrates the bug. main() { long bad=-2, good=-4; printf("Is this true?: -1=%ld, -1=%ld\n", bad >> 1, good >> 2); } My copy of TC++ generates an .exe which produces: Is this true?: -1=2147483647, -1=-1 This bug occurs only for shifts of longs, and only if the shift is by the constant "1". It is a bug in the generated code; the preprocessor does not have the bug and therefore cannot be used to detect the bug. The actual generated code is: shr ax,1 rcr dx,1 whereas the correct code would be: sar ax,1 rcr dx,1 -- --------------- Bill Metzenthen Mathematics Department Monash University Australia