[llvm-bugs] [Bug 37242] New: Feature request: do not assume size of struct with flexible array member

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 25 13:21:19 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37242

            Bug ID: 37242
           Summary: Feature request: do not assume size of struct with
                    flexible array member
           Product: clang
           Version: unspecified
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vicencb at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi
It would be nice to have a new option in clang (e.g.: -Wno-assume-size) that
reports a warning each time it needs to assume the size of a variable of
unknown size.

For example, the following code
struct strc { int a; int b[]; };
struct strc array_of_var_unknown_size[10];
struct strc *ptr1_to_var_unknown_size = array_of_var_unknown_size + 1;
struct strc *ptr2_to_var_unknown_size = array_of_var_unknown_size + 3;
unsigned diff = ptr2_to_var_unknown_size - ptr1_to_var_unknown_size;
should generate 4 of such warnings.

This would be useful for catching errors when dealing with structs which
contain a flexible array member.

Regards,
  Vicente.

-- 
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/20180425/8f1d658d/attachment-0001.html>


More information about the llvm-bugs mailing list