-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
I just tested your STACK tool with success as I found two bugs in our code base. Great work, many thanks! However, I came across a load of warnings that stem from C++ delete and delete[] operators, reported if the pointer to the deleted object was referenced before. The code:
int main()
{
char *ptr = new char[128];
*ptr = '\0';
delete[] ptr;
return 0;
}
produces the warning:
---
bug: anti-simplify
model: |
%4 = icmp eq i8* %1, null, !dbg !15
--> false
stack:
- /home/p/src/test/memory_test.cc:5:0
ncore: 1
core:
- /home/p/src/test/memory_test.cc:4:0
- null pointer dereference
This warning seems to be unnecessary since (I) ptr should never be NULL since new is supposed to throw an exception if the allocation fails and (II) delete should check for NULL values. Of course the situation is different for C malloc calls. Is there any reason why these warnings are included in your analysis of C++ codes? Is my understanding of the standard incorrect here?
Metadata
Metadata
Assignees
Labels
No labels