[LLVMbugs] [Bug 12289] New: -Wsizeof-pointer-memaccess doesn't catch memset( itemInfo, 0, sizeof( &itemInfo ) )

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Mar 16 19:01:09 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12289

             Bug #: 12289
           Summary: -Wsizeof-pointer-memaccess doesn't catch memset(
                    itemInfo, 0, sizeof( &itemInfo ) )
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: seth.cantrell at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following program does not produce a warning when compiling with
-Wsizeof-pointer-memaccess

#include <cstring>

struct Foo {};

int main() {
    Foo p, *itemInfo = &p;

    std::memset( itemInfo, 0, sizeof( &itemInfo ) );

}

If the memsset line were slightly different, a warning would be generated:

memset( itemInfo, 0, sizeof( itemInfo ) );

This code was tested due to the following article (Example 1):

http://www.viva64.com/en/a/0079/#ID0EYKAG

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list