[clang] [Clang] Diagnose UB and emit error when identifier has both internal and external linkage (PR #192116)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 16 06:44:24 PDT 2026


https://github.com/AaronBallman commented:

Thank you for working on this! This is actually a requirement for C2y now, because WG14 adopted https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3410.pdf

Note, CWG426 was adopted by WG21 in C++17 but the current wording now requires a particular behavior in C++: https://eel.is/c++draft/basic.link#4 (see the example in p6 as well). Amazingly, you can declare the variable as `extern` in C++ and it will have internal linkage (wow), and we definitely do not do that: https://godbolt.org/z/sYdxGaeer (look at the AST dump for the final declarations of `i` and `f` and see we give them external linkage while the standard now says they should have internal linkage). Changing this behavior in C++ will be an ABI break so I do not recommend trying to untangle the C++ bits in this PR -- that's better as a follow-up, IMO.

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


More information about the cfe-commits mailing list