On 06/07/2017 02:12 PM, Martin Sebor wrote: > On 06/07/2017 02:01 PM, Marc Glisse wrote: >> On Wed, 7 Jun 2017, Bernhard Reutner-Fischer wrote: >> >>> On 7 June 2017 16:46:53 CEST, Martin Sebor wrote: >>>> On 06/07/2017 02:23 AM, Richard Biener wrote: >>>>> On Wed, Jun 7, 2017 at 5:26 AM, Martin Sebor >>>> wrote: >>>>>>> Note I'd be _much_ more sympathetic to simply canonicalizing all of >>>>>>> bzero and bcopy >>>>>>> to memset / memmove and be done with all the above complexity. >>>>>> >>>>>> >>>>>> Attached is an updated patch along these lines. Please let me >>>>>> know if it matches your expectations. >>>>> >>>>> I think you attached the wrong patch. >>>> >>>> Yes I did, sorry. The correct one is attached. >>> >>> Under POSIX.1-2008 "optimizing" bzero or bcmp is IMO plain wrong. >>> >>> It's like optimizing foo() to a random built-in but maybe that's just >>> me. If your libc provides a define to a standard function for these >>> under a compat knob then fine but otherwise you should fix that. >>> *shrug*. Joseph? >> >> The patch optimizes __builtin_bzero, which should be ok. The question >> (independent from this patch) is then under what conditions bzero should >> be detected as a builtin. > > Yes. The problem is that unlike for C and C++, GCC doesn't have > a mechanism to select the target version of POSIX. I think it > should. > > But there is a subtle problem with the patch that needs fixing. > Bcopy should not be transformed to memcpy but rather memmove. > I'll fix that before committing. Attached is an updated patch with this fix. I also added a cast from bcopy and bzero to void to detect accidental uses of the return value. Tested on x86_64-linux. Martin