From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 18300 invoked from network); 13 Jul 1999 10:15:32 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 13 Jul 1999 10:15:32 -0000 Received: from mgw-x2.nokia.com (mgw-x2.nokia.com [131.228.20.22]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id GAA15297 for ; Tue, 13 Jul 1999 06:09:20 -0400 Received: from mgw-i2.ntc.nokia.com (mgw-i2.ntc.nokia.com [131.228.118.61]) by mgw-x2.nokia.com (8.9.3/8.9.3) with ESMTP id NAA22431 for ; Tue, 13 Jul 1999 13:09:00 +0300 (EETDST) Received: from ducati.uk.ntc.nokia.com (ducati.uk.ntc.nokia.com [131.228.132.169]) by mgw-i2.ntc.nokia.com (8.9.3/8.9.3) with SMTP id NAA11432 for ; Tue, 13 Jul 1999 13:08:58 +0300 (EETDST) Received: from mvagusta by ducati.uk.ntc.nokia.com (SMI-8.6/SMI-SVR4) id LAA07560; Tue, 13 Jul 1999 11:08:44 +0100 From: carmody@cpd.ntc.nokia.com (Phil Carmody) Received: (carmody@localhost) by mvagusta (SMI-8.6/8.6.9) id LAA05659; Tue, 13 Jul 1999 11:08:55 +0100 Date: Tue, 13 Jul 1999 11:08:55 +0100 Message-Id: <199907131008.LAA05659@mvagusta> To: axp-list@redhat.com In-reply-to: (abel@bfr.co.il) Subject: Re: an evil memcpy() optimizer bug! (egcs-1.1.2, alphaev6, linux) Mime-Version: 1.0 (generated by tm-edit 7.68) Content-Type: text/plain; charset=US-ASCII >>>>> "}" == Alexander L Belikoff writes: }> Joachim Wesner writes: >> Alexander L. Belikoff wrote: >> > "Wes Bauske" writes: >> > > Try modifying your code to pass the address of a double rather >> > > than the double itself and see if you still can create the >> > > problem. I've seen problems passing floats/doubles to functions >> > > rather than their addresses. I just pass the address instead. >> > As you may have noticed, I didn't talk about workaround - there are >> > many of them. The one, I'm using now is that I have a temporary >> > volatile double v2 in put_f8() and I copy v into v2 and use the >> > latter. Other possible workarounds include, compiling put_f8() with >> > optimization turned off (it is not time-critical), or using manual >> > 'for' loop, rather than memcpy(). >> YEP, but actually I'd say this is a feature, not a bug ! If I remember >> correctly written >> somewhere in C standard, a temporary double arg, that will be passed in >> a *register*, as you **will** like it to happen at maximum optimization, >> simply has **NO** address to pass to memcpy. At best, the compiler can >> warn you and automatically generate one of the above workarounds you >> mention (with the SAME drawbacks), I don't think/expect there to exist a >> compiler smart enough to replace your case with one single optimized >> inline register to memory store or whatever. Or ??? Eeeek! }> Thank you for a very clear explanation. May I hope for a reference in }> the standard or the Steel book? This really starts to scare me now - }> what other surprises does the standard have? Rewind, and erase. The 'YEP' paragraph has no connection to the ISO C language at all. There is no way an C coder can specify that a register be used for either a variable or a parameter. One may hint, or suggest, but not specify. It it the compiler's responsibility to ensure that anything one takes the address of has an address, and thus is not solely stored in a register. It was a bug, which is why it appears to have been fixed. Compilers, however, are permitted to keyhole optimise and convert known length calls to functions like memcpy into more efficient code. MSVC++ does this without even breaking into a sweat. Phil