This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/61806] [C++11] Expression sfinae w/o access gives hard error in partial template specializations


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

gcc-bugs at marehr dot dialup.fu-berlin.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc-bugs at marehr dot dialup.fu-b
                   |                            |erlin.de

--- Comment #3 from gcc-bugs at marehr dot dialup.fu-berlin.de ---
I think I encountered a variant of this bug.

Using this new awesome -fconcept feature, you can do the following:

```
template <typename type_t>
struct type_trait;

template <>
struct type_trait<int>
{
    static constexpr auto length = 0;
};

template <>
struct type_trait<long>
{
private:
    static constexpr auto length = 0;
};

template <typename type_t>
concept bool has_length = requires(type_t a)
{
    { type_trait<type_t>::length };
};

int main()
{
    static_assert(!has_length<char>); // expect: false, has no ::length
    static_assert(has_length<int>); // expect: true, has ::length
    static_assert(!has_length<long>); // expect: false, ::length is non-visible
    // but, last one fails in a compiler error
    return 0;
}
```

This example asks whether a type_trait is defined for a given type. And it
would be super useful to be able to express this.

I think gcc uses internally SFINAE to check this but unfortunately fails
because of this bug (probably).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]