X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Ben Pfaff Newsgroups: comp.os.msdos.djgpp,comp.lang.c Subject: Re: gcc 2.953 output - is this a bug? Date: 06 Feb 2002 18:39:29 -0800 Lines: 29 Sender: blp AT pfaff DOT stanford DOT edu Message-ID: <87d6zim2vy.fsf@pfaff.stanford.edu> References: <3C61E6BB DOT 7F9AD526 AT yahoo DOT com> NNTP-Posting-Host: pfaff.stanford.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com CBFalconer writes: > Please look at the following disassembly: > > h = h * 37UL + (unsigned char) *string++; > 585: 8d 04 d2 lea (%edx,%edx,8),%eax <<*** > 588: 8d 04 82 lea (%edx,%eax,4),%eax <<*** > > look at the lines marked "<<***". I fail to see how this > implements h * 37UL. Why, you mean it's not perfectly obvious? :-) Here's a translation back to C of these lines: eax = edx + 8 * edx eax = edx + 4 * eax Here's an equivalent for the first line: eax = 9 * edx which, performing a substitution on eax, means that the second line becomes equivalent to eax = edx + 4 * (9 * edx) and from there it should be evident. (GCC is more clever than I thought.) [snippage] -- "It would be a much better example of undefined behavior if the behavior were undefined." --Michael Rubenstein