Issue 133047
Summary [Clang] template with NTTP param is static array element failed to compile
Labels clang
Assignees
Reporter wanghenshui
    it's code from CV-cuda, migrate to clang

```c++
#include <cstddef>
#include <stdint.h>
#include <utility>
#include <tuple>
template<bool Active = true, typename T>
constexpr inline bool IsOutside(T c, T s)
{
    if constexpr (Active)
    {
        return (c < 0) || (c >= s);
    }
 return false;
}


template<bool... ActiveDimensions>
class BoolDimension
{
public:
    static constexpr int  kNumDimensions = sizeof...(ActiveDimensions);
    struct ActiveMap
    {
        bool from[kNumDimensions];

        constexpr ActiveMap()
            : from()
        {
            int j = 0;
            for (int i = 0; i < kNumDimensions; ++i)
            {
                if (kActiveDimensions[i])
                {
                    from[i] = j++;
                }
            }
        }
    };

    static constexpr ActiveMap kMap{};
    static constexpr bool kActiveDimensions[]  = {ActiveDimensions...};
    static constexpr int  kNumActiveDimensions = ((ActiveDimensions ? 1 : 0) + ...);
    int64_t m_tensorShape[kNumActiveDimensions] = {0};

    template<typename... Args, std::size_t... Is>
    inline  bool check(std::index_sequence<Is...>, Args... c) const
    {
        //static constexpr const  auto kDimensions = std::make_tuple(ActiveDimensions...);
        //if ((IsOutside<std::get<Is>(kDimensions)>(c,false) || ...))
        if ((IsOutside<kActiveDimensions[Is]>(c,false) || ...))
        {
 return true;
        }
        return false;
    }
};

int main() {
 BoolDimension<true, true, false, false> d;
    constexpr auto Is = std::make_index_sequence<1>{};
    return d.check(Is, false);
}
```

in check function, IsOutside not accept array element, change to tuple with get is ok

https://godbolt.org/z/n1K5vGcrE


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to