[llvm-bugs] [Bug 40227] New: c11: Accepts invalid program with incompatible function types.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 4 07:23:55 PST 2019


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

            Bug ID: 40227
           Summary: c11: Accepts invalid program with incompatible
                    function types.
           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):

  void f()
  {
  }

  int main()
  {
    void (*g)(int) = 0;
    &f == g;
  }

Compilation command line:

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

Observed behaviour:

  No error messages outputed.

Expected behaviour:

  An error message outputed.

  The program is invalid due to the following paragraphs of the standard:

  6.5.9/2:

  "One of the following shall hold:
   —  both operands have arithmetic type;
   —  both operands are pointers to qualified or unqualified versions of
      compatible types;
   —  one operand is a pointer to an object type and the other is a pointer to
a 
      qualified or unqualified version of void; or
   —  one operand is a pointer and the other is a null pointer constant."

  6.7.6.3/15:

  "... If one type has a parameter type list and the other type is specified by
   a function definition that contains a (possibly empty) identifier list, both
   shall agree in the number of parameters, and the type of each prototype
   parameter shall be compatible with the type that results from the
application
   of the default argument promotions to the type of the corresponding
   identifier. ..."

-- 
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/20190104/452cbd6c/attachment.html>


More information about the llvm-bugs mailing list