On 8/23/24 3:49 PM, Arsen Arsenović wrote:
Iain Sandoe <i...@sandoe.co.uk> writes:

static tree
get_awaitable_var (suspend_point_kind suspend_kind, tree v_type)
{
-  static int awn = 0;
+  auto cinfo = get_coroutine_info (current_function_decl);
+  gcc_assert (cinfo);

If the purpose of this is to check for mistakes during development (i.e. we do
not see a reason for having it in a released compiler) - then it’s better to use
gcc_checking_assert() which will disappear for non-checking builds.

I figured it was OK since this check is extremely light - I can use
gcc_checking_assert if you prefer.  No strong feelings in this instance.

In addition to the expense consideration, I think of _checking_ as being for things that I expect to be true, but the code might do something reasonable even if they aren't, and gcc_assert for things where the result is going to be complete nonsense if it isn't true.

Here, it'll immediately SEGV when trying to dereference a null pointer anyway in most cases, just not in the INITIAL/FINAL_SUSPEND_POINT cases. They don't seem to have any dependence on nonnull cinfo, so I think _checking_ is the right choice.

OK with that tweak and the testsuite fix.

Jason

Reply via email to