Skip to content

Inconsistent behavior between GCC and Clang for __queryable_with with composed environments #1840

@romintomasetti

Description

@romintomasetti

The following code produces different results on Clang and GCC:

constexpr struct FwdFoo
    : STDEXEC::__query<FwdFoo>
    , STDEXEC::forwarding_query_t {
    using STDEXEC::__query<FwdFoo>::operator();
  } fwd_foo{};

constexpr struct Foo : STDEXEC::__query<Foo> {
  } foo{};

constexpr struct Bar : STDEXEC::__query<Bar> {
  } bar{};

constexpr bool test() {
auto env = STDEXEC::env{
        STDEXEC::env{STDEXEC::prop{fwd_foo, 42.}, STDEXEC::prop{foo, 'F'}},
        STDEXEC::prop{                        bar,                   31415}
      };

      static_assert(!STDEXEC::__queryable_with<decltype(env), Foo>); // clang agree, but not gcc !

      return fwd_foo(env) == 42. && bar(env) == 31415;
}
static_assert(test());

The assertion fails for gcc (tried out 12, 13, 14 and 15). I'm not sure what the expected behavior should be.

When the foo property is defined in the nested environment, and since it is not a forwarding query:

Should the outer environment be queryable for foo ?

@ericniebler I think it's important that this gets tested/standardized properly and consistently, as composing environments is something we do, but also nvexec and some standardized algorithms.

Here is a godbolt reproducer.

Joint work with @maartenarnst.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions