☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

函数指针被转为不兼容的类型并执行

C++-Undefined-Behavior-35
目录 › next › previous

示例:

void foo();

return ((int(*)())(&foo))();  // Undefined behavior

例中 foo 函数没有返回值,将其强转为有返回值的函数并调用,会导致未定义的行为。

依据

ISO/IEC 14882:2003 5.2.10(6)-undefined ISO/IEC 14882:2011 5.2.10(6)-undefined

规则

ID_functionPointerCast
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.