On Wed, 6 Nov 2024, Alexander Monakov wrote: > > On Wed, 6 Nov 2024, Richard Biener wrote: > > > Since we had malloc/free pair removal for quite some time I think > > it should stay on by default. > > I missed that; now I see what you meant by "not making the existing > situation worse". > > I still miss what happened to "correctness trumps performance" :)
Heh, fair. Note I have mixed opinions on some language/library features like that dreaded errno ... We're mostly competing on the level of performance, not so much on strict conformance for cases that unlikely happen in practice. So what I don't like is taking the optimization away from people - we can always default to strict conformance but traditionally at least compiler sided on optimization with options for strict conformance. We're just very inconsistent here. > Between this and floating-point defaults I have a feeling we keep > doing the opposite of what the informed users are asking for. > > I would like to remind of the calloc issue exacerbated by this patch: > when the product of calloc arguments would wrap around, it must return > NULL. The argument is that a program doesn't perform calloc to check for overflow, it does to allocate memory, use it and then relase it. If the use is dead it's not interesting whether the allocation would have never succeeded - it's only interesting for conformance tests. > I didn't see a discussion of a more gentle approach where instead of > replacing the result of malloc with a non-zero constant, we would change > > tmp = malloc(sz); > > to > > tmp = (void *)(sz <= SIZE_MAX / 2); > > and let the following optimizations fold that further based on sz's range. > Is there some issue with that that I'm not seeing? No, I liked this idea, but of course it will eventually fail to optimize abstraction - it's also again mostly relevant for conformance testing. Richard. > Thank you. > Alexander > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)