[libcxx-commits] [libcxx] [libc++] Enable availability based on the compiler instead of __has_extension (PR #84065)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 6 15:18:15 PST 2024


ldionne wrote:

Personally, I view `-pedantic-errors` as something that means more or less `-Werror -Wpedantic`, and I think it's extremely confusing that warning flags would change the semantics of code, not just the diagnostics you get. When we allow changing semantics of code based on things that look like diagnostics, we can end up with things as surprising as ODR violations based on what the user thinks is a warning flag. That feels extremely surprising and undesirable to me.

I do understand the desire to check whether using an extension is going to produce an error, but I think that desire is misguided in most cases -- what people really want to know is whether the compiler they use supports the extension. In case you're writing a library and you want to allow people to compile with pedantic diagnostics, you should

1. Check for `__has_extension` to know whether the compiler supports the extension
2. Use pragmas to silence the usage of non-standard extensions to support users turning on these diagnostics


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


More information about the libcxx-commits mailing list