[LLVMbugs] [Bug 15535] New: warn on (sometimes?) dereference of one-past-end pointer

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 17 18:50:54 PDT 2013


            Bug ID: 15535
           Summary: warn on (sometimes?) dereference of one-past-end
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicholas at mxc.ca
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I'd like something like -Wuninitialized/-Wsometimes-uninitialized but which
keeps track of pointers that are known to point to one-past-the-end of an
array, and warn when dereferenced.

For motivation, see the example code in bug 15522 which clang issues no
warnings for. If the program instead asked for "long *pk = &buf[3];" clang
would issue a warning with -Warray-bounds because that's two past the end of
the array and consequently always invalid.

  char buf[2];
  char *p = &buf[2];
  *p = '\0';  // please warn here.

Also, using the same logic from the -Wsometimes-uninitialized flag, I'd also
like this:

  char buf[2];
  char *p = &buf[2];
  if (condition) {
    *p = '\0';  // please warn in here as well.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130318/6f53c87b/attachment.html>

More information about the llvm-bugs mailing list