AaronBallman wrote:

> In C++26, exceptions are allowed in a constant evaluated context, which is 
> used extensively by reflection and maybe P2300.

Good point. :-/

> I also think allowing `try` not to be a keyword in some modes would harm the 
> ecosystem.

[citation needed]

You already cannot safely link code which disables exceptions into code which 
enables exceptions due to ABI issues, so I'm really not certain what harm would 
come from letting users use these identifiers themselves if they elect to 
ignore the language feature.

> Here is an interesting scenario
> 
> ```c++
> constexpr void g() {
>    throw 42;
> } 
> 
> constexpr int f() {
>    try {g(); } catch {}
>    return 0;
> }
> static_assert(f() == 0); // the call to g() from here should be allowed
> 
> int main() {
>   return f(); //  but not here if we want to disallow exceptions
> }
> ```
> 
> So, now that I think about it, doing it at code gen is the only solution post 
> C++26

I disagree. If the user disabled exceptions, why would they expect them to work 
in constant expressions?

https://github.com/llvm/llvm-project/pull/139859
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to