Skip to content

Deduced return type and SFINAE bug #109

@M-Kusumgar

Description

@M-Kusumgar

Minimal example of bug: https://godbolt.org/z/91Tz6sbcx

In the example above, auto is being deduced as std::tuple<> instead of std:tuple<long int> by the compiler. Since we do not provide loop over in the example above, it should use this specialisation, however in computing

class = internal::enable_if_callable<Fn, typename Shape::index_type>

the compiler tries to deduce the return type of the function and produces an actual error (see this for more detail) which causes the other specialisation of for_each_index to be used, and since loop order is not provided, index_of_rank<sizeof...(LoopOrder)> evaluates to std::tuple<>.

There is a workaround for the bug by explicitly defining the return type of the lambda: https://godbolt.org/z/9bob8TYdd (added a -> void) however perhaps the sizeof...(LoopOrder) conditions should be the first enable ifs in the template parameters and specialisations should be done based on that?

I just found the bug but credit to @plietar for figuring this out

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