[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p3 requirements (PR #101853)

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 15 14:52:11 PDT 2024


alexfh wrote:

Hi @a-tarasyuk, it looks like this patch introduces a couple of problems. I guess, this boils down to marking the declaration of main() invalid in case it's declared with `extern "C"`, but I may be wrong here.

The first problem is a clang crash: https://gcc.godbolt.org/z/dWETErhzM

The second one is a change of behavior of code that declares `main()` `extern "C"` (see my comment https://github.com/llvm/llvm-project/commit/37ec6e5f12afe4a37872bf28f280423696f39019#r145380228). This one still needs some work to create a standalone repro for, but I suspect that both issues are related to marking the declaration invalid.

The problem with both cases is that in some codebases the non-trivial amount of cleanup is necessary for this, but Clang doesn't allow to retain the old behavior by just ignoring the diagnostic (`-Wno-main`). Even if the diagnostic is not issued, the issues above still manifest.

Please fix this ASAP or revert the patch, if it requires non-trivial / controversial changes or further discussion.

Thanks!

https://github.com/llvm/llvm-project/pull/101853


More information about the cfe-commits mailing list