llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.92k stars 11.52k forks source link

Clang crashes when calling an explicit object member function before it is declared. #102025

Closed ldalessa closed 4 weeks ago

ldalessa commented 1 month ago

I'm working on a little project that uses C++16 and does a bunch of compile time programming and metaprogramming, and I've run into this ICE. bind-4ddf5a.sh.gz bind-4ddf5a.cpp.gz

ldalessa commented 1 month ago

Manually reduced to something like this (note that the code isn't valid).

#include <utility>

struct Foo {
    template <class T>
    constexpr auto operator[](this T&& self, auto... i) -> decltype(_evaluate(std::forward<T>(self), i...)) {
        return self._evaluate(i...);
    }

private:
    template <class T>
    constexpr auto _evaluate(this T&& self, auto... i) -> decltype((i + ...)) ;
};

int main()
{
    Foo foo;
    return foo[];
}

https://godbolt.org/z/j5EfGYYWE

llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-frontend

Author: Luke D'Alessandro (ldalessa)

I'm working on a little project that uses C++16 and does a bunch of compile time programming and metaprogramming, and I've run into this ICE. [bind-4ddf5a.sh.gz](https://github.com/user-attachments/files/16500926/bind-4ddf5a.sh.gz) [bind-4ddf5a.cpp.gz](https://github.com/user-attachments/files/16500927/bind-4ddf5a.cpp.gz)