[llvm-bugs] [Bug 40197] New: c11: Rejects valid program dereferencing pointer with incomplete reference type.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 1 11:05:31 PST 2019


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

            Bug ID: 40197
           Summary: c11: Rejects valid program dereferencing pointer with
                    incomplete reference type.
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: anders.granlund.0 at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Test case (prog.c):

  struct S *p;

  void f(void);

  int main()
  {
    f();

    *p;
  }

  struct S { int x; };

  void f()
  {
    static struct S s = { 0 };
    p = &s;
  }

Compilation command line:

  clang prog.c -Wall -Wextra -std=c11 -pedantic-errors

Observed behaviour:

  The following error message was outputed:

    prog.c:9:5: error: incomplete type 'struct S' where a complete type is
    required
        *p;
        ^
    prog.c:1:8: note: forward declaration of 'struct S'
    struct S *p;
           ^

Expected behaviour:

  No error message outputed.

  I can't find anything in the standard that makes the this program invalid.

-- 
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/20190101/05c0731a/attachment.html>


More information about the llvm-bugs mailing list