我要评分
获取效率
正确性
完整性
易理解

Different Running Behaviors of Non-void Functions Without Return Values

Error Information

1
2
warning: non-void function does not return a value in all control paths [-Wreturn-type]
Trace/breakpoint trap (core dumped)

Problem

For binary security purposes, the compiler inserts invalid instructions into branches that do not return values, which may cause a core dump during runtime.

Solution

  • Add return values for non-void functions.
  • Change the type of functions that do not return values to void.
  • Use the clang-tidy tool to identify such issues and provide modification suggestions.