[PATCH] D131351: [C] Default implicit function pointer conversions diagnostic to be an error

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 7 06:12:41 PDT 2022


aaron.ballman created this revision.
aaron.ballman added reviewers: erichkeane, jyknight, efriedma, clang-language-wg.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

Implicitly converting between incompatible function pointers in C is currently a default-on warning (it is an error in C++). However, this is very poor security posture. A mismatch in parameters or return types, or a mismatch in calling conventions, etc can lead to exploitable security vulnerabilities. Rather than allow this unsafe practice with a warning, this patch strengthens the warning to be an error (while still allowing users the ability to disable the error or the warning entirely to ease migration). Users should either ensure the signatures are correctly compatible or they should use an explicit cast if they believe that's more reasonable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/overloadable.c
  clang/test/Sema/aarch64-svepcs.c
  clang/test/Sema/aarch64-vpcs.c
  clang/test/Sema/arm-cmse.c
  clang/test/Sema/attr-nocf_check.c
  clang/test/Sema/block-return.c
  clang/test/Sema/c2x-func-prototype.c
  clang/test/Sema/callingconv-ms_abi.c
  clang/test/Sema/callingconv-sysv_abi.c
  clang/test/Sema/callingconv.c
  clang/test/Sema/incompatible-function-pointer-types.c
  clang/test/Sema/initialize-noreturn.c
  clang/test/Sema/noescape.c
  clang/test/Sema/overloadable.c
  clang/test/Sema/pass-object-size.c
  clang/test/Sema/preserve-call-conv.c
  clang/test/SemaObjC/comptypes-legal.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131351.450617.patch
Type: text/x-patch
Size: 22310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220807/521018cf/attachment-0001.bin>


More information about the cfe-commits mailing list