This is an archive of the discontinued LLVM Phabricator instance.

free(nullptr) does not violate the nofree specification

Authored by reames on Apr 19 2021, 11:24 AM.



This fixes a subtle and nasty bug in my 86664638. The problem is that free(nullptr) is well defined (and common).

The specification for the nofree attributes talks about memory objects, and doesn't explicitly address null, but I think it's reasonable to assume that nofree doesn't disallow a call to free(nullptr). If it did, we'd have to prove nonnull on an argument to ever infer nofree which doesn't seem to be the intent.

This was found by Nuno and Alive2 over in Once I saw the test case (and explanation Nuno provided), I also suspect this is the root cause of as well. (Though that had at least two root issues, so there might be more as well.)

Diff Detail

Event Timeline

reames created this revision.Apr 19 2021, 11:24 AM
reames requested review of this revision.Apr 19 2021, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2021, 11:24 AM
This revision is now accepted and ready to land.Apr 19 2021, 4:43 PM
This revision was landed with ongoing or failed builds.Apr 20 2021, 9:08 AM
This revision was automatically updated to reflect the committed changes.