[LLVMbugs] [Bug 18875] New: No warning for function call through a non-compatible type

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 17 12:00:39 PST 2014


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

            Bug ID: 18875
           Summary: No warning for function call through a non-compatible
                    type
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang does not warn a function call through a non-compatible type. Such a
function call can lead to unexpected behavior, such as the following code. 

$: cat s.c
int foo(double *x) {return (int)*x;}
typedef int (*F)(int*);
int main() {
  int x = 0;
  return ((F)foo)(&x);
}
$: clang-trunk -Weverything -Wno-missing-prototypes s.c
$: gcc-trunk s.c
s.c: In function ‘main’:
s.c:5:10: warning: function called through a non-compatible type
   return ((F)foo)(&x);
          ^
$
$: clang-trunk --version
clang version 3.5 (trunk 201498)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
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/20140217/5f902fec/attachment.html>


More information about the llvm-bugs mailing list