https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90629

David Binderman <dcb314 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcb314 at hotmail dot com

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---

Here is a little test case:

// bad alloc & dealloc

# include <stdlib.h>

void
f()
{
        char * p = new char [ 10];
        delete p;

        char * p2 = new char;
        delete [] p2;

        char * q = new char [ 10];
        free( q);

        char * q2 = (char *) malloc( 10);
        delete [] q2;
}

Latest gcc finds no problems, latest clang finds two, for p and p2.
q and q2 not found.

Interestingly, I've just started compiling all of fedora distribution
with clang. I've only compiled [a-d]*.spec files so far, but I have 34 cases
found already. This implies about 220 cases in fedora.

So only duplicating what does clang for new and delete would find hundreds of
bugs in fedora. I'd be glad to help with testing any prototype implementation.

Reply via email to