You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Weston Pace (Jira)" <ji...@apache.org> on 2022/06/02 20:25:00 UTC

[jira] [Created] (ARROW-16743) [C++] Add short-circuit version of logical Status AND

Weston Pace created ARROW-16743:
-----------------------------------

             Summary: [C++] Add short-circuit version of logical Status AND
                 Key: ARROW-16743
                 URL: https://issues.apache.org/jira/browse/ARROW-16743
             Project: Apache Arrow
          Issue Type: Improvement
          Components: C++
            Reporter: Weston Pace


{{Status}} overloads the {{&}} operator as in (from file_base.cc):

{noformat}
finished_.MarkFinished(dw_status & finish_st & tg_status);
{noformat}

However, it also sometimes used as (from scalar.cc):

{noformat}
return StdHash(s.value.days) & StdHash(s.value.milliseconds);
{noformat}

This latter form is technically correct (in this case) because {{StdHash}} has no side effects and there is no real need to short-circuit.  However, this can be very misleading.  The compiler is allowed to reorder these statements as it wants.  This led to trouble in https://github.com/apache/arrow/pull/13232 because I suggested something like...

{noformat}
return Foo(value) & Bar(std::move(value));
{noformat}

Now, for a C++ expert, this may have been immediately obvious.  However, I think we can simplify things by adding the {{&&}} operator for {{Status}} to allow:

{noformat}
return Foo(value) && Bar(std::move(value));
{noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)