C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Filip <fph2137_at_[hidden]>
Date: Thu, 15 Jan 2026 10:53:54 +0100
return if appears to be basically an assert that does not stop your program from running.

Maybe it is better to just use something similar to assert?

```
1. soft_assert(foo());
2. soft_assert(foo(), default_return_value);
```

> On 14 Jan 2026, at 16:32, Ville Voutilainen via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> On Wed, 14 Jan 2026 at 17:30, Thiago Macieira via Std-Proposals
> <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>> wrote:
>>
>> On Wednesday, 14 January 2026 06:57:00 Pacific Standard Time Frederick
>> Virchanza Gotham via Std-Proposals wrote:
>>> extern int &&CalleeFunction(void);
>>>
>>> int &&EnclosingFunction(void)
>>> {
>>> decltype(auto) x = CalleeFunction();
>>> if ( x ) return x;
>>> }
>>
>> Compiles with GCC and Clang, albeit with a warning that it reaches the end of
>> a non-void function without a return. The old ICC (with the EDG front-end) and
>> MSVC don't like it:
>>
>> https://gcc.godbolt.org/z/WcoEb8ehM
>
> At any rate, that has nothing to do with value categories and how
> decltype(auto) works, and changes exactly
> nothing in how the "return if" is just an unnecessary dead duck that
> doesn't even simplify anything.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden] <mailto:Std-Proposals_at_[hidden]>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals


Received on 2026-01-15 09:54:11