llvm / llvm-project

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

Implementing friend operator with two exclusive requires clauses but same name of requirement causes "error: redefinition of 'operator<<'" #89909

Open gsamatt opened 4 months ago

gsamatt commented 4 months ago

This does not compile with clang 18 but it does with clang 17: https://godbolt.org/z/orMfTfxMd

This would compile with both compiler as it uses a different name for the requirement: https://godbolt.org/z/Mjxq54abb

llvmbot commented 4 months ago

@llvm/issue-subscribers-clang-frontend

Author: None (gsamatt)

This does not compile with clang 18 but it does with clang 17: https://godbolt.org/z/orMfTfxMd This would compile with both compiler as it uses a different name for the requirement: https://godbolt.org/z/Mjxq54abb
Sirraide commented 4 months ago

Reduced (https://godbolt.org/z/Yzcdca6a1):

struct A {
    template <typename M> static constexpr bool C = true;
    template <typename M> friend void f() requires (C<M>) {}
};

struct B {
    template <typename M> static constexpr bool C = false;
    template <typename M> friend void f() requires (C<M>) {}
};