On 11 January 2018 at 04:50, Jeff Law <l...@redhat.com> wrote: > On 01/09/2018 05:57 AM, Prathamesh Kulkarni wrote: >> >> As Jakub pointed out for the case: >> void *f() >> { >> return __builtin_malloc (0); >> } >> >> The malloc propagation would set f() to malloc. >> However AFAIU, malloc(0) returns NULL (?) and the function shouldn't >> be marked as malloc ? > This seems like a pretty significant concern. Given: > > > return n ? 0 : __builtin_malloc (n); > > Is the function malloc-like enough to allow it to be marked? > > If not, then ISTM we have to be very conservative in what we mark. > > foo (n, m) > { > return n ? 0 : __builtin_malloc (m); > } > > Is that malloc-like enough to mark? Not sure. Should I make it more conservative by marking it as malloc only if the argument to __builtin_malloc is constant or it's value-range is known not to include 0? And similarly for __builtin_calloc ?
Thanks, Prathamesh > Jeff