https://bugs.llvm.org/show_bug.cgi?id=50989

            Bug ID: 50989
           Summary: ICE on valid, templated friend injection cause ICE,
                    invalid template parameters, true and false at the
                    same time assert condition
           Product: clang
           Version: 8.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Hi,

I've stumbled upon a really weird bug with how friends are handled by clang.
The following causes invalid template parameters to be introduced and an ICE.

It's present since clang 8.0 and is still present in trunk.
Befoer clang 8, the friend was just never instantiated, which was also invalid.

Here a compiler-explorer link to the issue: https://godbolt.org/z/qzM41rrKG

Or here, the a minimal example:
```
#include <type_traits>

template<class...> struct type_t {};

struct A {};

template<class... Args>
void fn(A, type_t<Args...>);

template<int N>
void nothing() {}

struct fn_arg {};
struct class_arg {};

template<class T>
struct B
{
    template<class... Args>
    friend void fn(A, type_t<Args...>) {
        static_assert(std::is_same<T, fn_arg>::value, "Should be class_arg!");

        static_assert(sizeof...(Args) != 0, "ok");
        static_assert(sizeof...(Args) == 0, "What?");
        constexpr auto n = sizeof...(Args);
        nothing<n>(); //ICE!
    }
};

void func(B<class_arg> = {}) {}

int main()
{
    fn(A{}, type_t<fn_arg>{});
}

```

Thanks in advance

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to