[PATCH] D143430: [C2x] Implement the `unreachable` macro for WG14 N2826

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 15 06:40:38 PST 2023


aaron.ballman added inline comments.


================
Comment at: clang/lib/Headers/stddef.h:108
+    __STDC_VERSION__ >= 202000L
+#define unreachable() __builtin_unreachable()
+#endif /* defined(__need_STDDEF_H_misc) && >= C23 */
----------------
erichkeane wrote:
> Is this REALLY required to be a macro by standard?  Is it so they don't have to steal the word/can do #undef?  This is going to result in a worse diagnostic here any time we diagnose on this line.
Yes, it's required to be a macro by the C standard.  According to my personal notes:

This led us up to a preference poll, does WG14 prefer the syntax variant over the macro variant in N2826? 3/12/5 (no consensus). Does WG14 prefer to put the macro into <stddef.h> as in N2826 in C23? 11/2/7 (consensus). Does WG14 want to adopt the unreachable feature Change 5 & 6 with stddef.h in place of HEADER.h into C23? 13/2/6 (consensus).

I don't think the diagnostic behavior here will be any different than for `offsetof` (defined a few lines below), right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143430/new/

https://reviews.llvm.org/D143430



More information about the cfe-commits mailing list