https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103333

--- Comment #1 from Lénárd Szolnoki <leni536 at gmail dot com> ---
This can be turned into wrong-code.

C++11 example without includes:

```
template <bool, typename = void>
struct enable_if {};

template <typename T>
struct enable_if<true, T> {
    using type = T;
};

template <bool b, typename T = void>
using enable_if_t = typename enable_if<b, T>::type;

template <typename T>
struct type_identity {
    using type = T;
};

template <typename T>
using type_identity_t = typename type_identity<T>::type;

template <typename T>
struct is_const {
    static constexpr bool value = false;
};

template <typename T>
struct is_const<const T> {
    static constexpr bool value = true;
};

template<typename T, bool b>
struct S{
    template<bool sfinae = true,
             typename = enable_if_t<sfinae && !is_const<T>::value>>
    operator S<T const, b>() { return {}; }

    operator int() { return 0; }
};

inline int f(int, int) {
    return 1;
}

template<typename T, bool b1, bool b2>
int f(S<const type_identity_t<T>, b1>,
       S<T, b2>) {
    return 2;
}

int main() {
    S<int, true> s1{};
    S<int, false> s2{};
    return f(s1, s2); // returns 2, should return 1
}
```

https://godbolt.org/z/h8b75P7GK

Reply via email to