Skip to content

Conditional masking is accepted where it cannot work #2379

Description

@jfalcou

Two shapes of callable accept a conditional they cannot honour. Both are silent at the call site.

Tuple-returning functions on a conditional base. A mask means "return the input where false", which has no meaning when the return type is a tuple. Six of the seventeen were tried; five fail to instantiate, deep inside EVE rather than at the call:

eve::frexp[false](1.5)
conditional.hpp:31:65: error: could not convert 'a0' from 'double'
                       to 'kumi::tuple<double,double>::binder_t'

Same for modf, two_add, lohi, rat. The seventeen: airy, frexp, ifrexp, lohi, minmax, modf, rat, sincos, sinhcosh, lambert, three_fma, two_add, two_sub, two_prod, two_div_approx, two_fma_approx, two_sqrt_approx.

minmax is the exception and the worse case: on tuple_callable it compiles and returns the first argument in both slots.

eve::minmax[false](1.0, 2.0) = 1, 1
eve::minmax[true ](1.0, 2.0) = 1, 2

logical_not drops its mask. Its operator() returns !a directly instead of going through EVE_DISPATCH_CALL, so the conditional never reaches the implementation.

eve::logical_not(false)        = true
eve::logical_not[false](false) = true     // expected false
eve::is_ltz[false](-5.0)       = false    // same shape, honoured

Two decisions, independent of one another: whether the tuple-returning set should move to eve::callable, which rejects [cond] at the call site with a message naming the function; and whether minmax returning {a, a} is intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions