Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior

2024-04-03 Thread Jason Merrill
On 4/3/24 15:16, Jakub Jelinek wrote: On Wed, Apr 03, 2024 at 12:58:12PM -0400, Jason Merrill wrote: On 4/3/24 12:42, Jakub Jelinek wrote: On Wed, Apr 03, 2024 at 12:07:48PM -0400, Jason Merrill wrote: Using std::is_constant_evaluated directly in a loop condition is, as the paper says, unlikel

Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior

2024-04-03 Thread Jakub Jelinek
On Wed, Apr 03, 2024 at 12:58:12PM -0400, Jason Merrill wrote: > On 4/3/24 12:42, Jakub Jelinek wrote: > > On Wed, Apr 03, 2024 at 12:07:48PM -0400, Jason Merrill wrote: > > > Using std::is_constant_evaluated directly in a loop condition is, as the > > > paper says, unlikely and "horrendous code",

Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior

2024-04-03 Thread Jason Merrill
On 4/3/24 12:42, Jakub Jelinek wrote: On Wed, Apr 03, 2024 at 12:07:48PM -0400, Jason Merrill wrote: Using std::is_constant_evaluated directly in a loop condition is, as the paper says, unlikely and "horrendous code", so I'm not concerned about surprising effects, though I guess we should check

Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior

2024-04-03 Thread Jakub Jelinek
On Wed, Apr 03, 2024 at 12:07:48PM -0400, Jason Merrill wrote: > Using std::is_constant_evaluated directly in a loop condition is, as the > paper says, unlikely and "horrendous code", so I'm not concerned about > surprising effects, though I guess we should check for it with > maybe_warn_for_consta

Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior

2024-04-03 Thread Jason Merrill
On 4/3/24 03:25, Jakub Jelinek wrote: Hi! The following patch attempts to implement P2809R3, which has been voted in as a DR. The middle-end has its behavior documented: '-ffinite-loops' Assume that a loop with an exit will eventually take the exit and not loop indefinitely. This a

Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior

2024-04-03 Thread Jakub Jelinek
On Wed, Apr 03, 2024 at 09:35:07AM +0200, Richard Biener wrote: > Just in case making the control expression constant to the middle-end > doesn't scale. I think we need to evaluate it as constant expression in any case, that is the only way to determine if it is trivial infinite loop or not. The c

Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior

2024-04-03 Thread Richard Biener
On Wed, Apr 3, 2024 at 9:25 AM Jakub Jelinek wrote: > > Hi! > > The following patch attempts to implement P2809R3, which has been voted > in as a DR. > > The middle-end has its behavior documented: > '-ffinite-loops' > Assume that a loop with an exit will eventually take the exit and > n