-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing featurequality-of-implementation
Description
The cleanup attribute is written on a variable declaration, and the address of the declared variable is passed to the specified function in the attribute. This has some subtle issues we should diagnose on. Consider:
__attribute__((cleanup(free))) void *p = malloc(10);
This will pass &p to free, which is going to do the wrong thing. GCC diagnoses this kind of misuse (warning: 'free' called on unallocated object 'p' [-Wfree-nonheap-object]) and it would be good if we did the same: https://godbolt.org/z/nhqh9EazM
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing featurequality-of-implementation