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

            Bug ID: 70213
           Summary: Not all ambiguous cases of method constraint
                    overloading caught?
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xyzdragon at fastmail dot fm
  Target Milestone: ---

I'm really a complete novice on the topic of concepts, but I read
  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3701.pdf
and on page 5 it introduces constraints for class methods.

    #include <iostream>

    class A {};

    template<class T> bool constexpr isConst() { return false; }
    template<> bool constexpr isConst<A>() { return true; }

    template<class T>
    struct B {
        void echo(void) requires isConst<T>()
        { std::cout << "isConst" << std::endl; };

        void echo(void) requires isConst<T>() && true
        { std::cout << "isConst && true" << std::endl; };

        /*
        concepts.cpp:131:13: error: call of overloaded 'echo()' is ambiguous
         ba.echo();
            => weirdly the above two functions don't return such ambiguity ...
        */
        //void echo(void) requires isConst<T>() && true && true;

        void echo(void) requires isConst<T>() && true || false
        { std::cout << "isConst && true || false" << std::endl; };
    };

    int main( void )
    {
        B<A> ba;
        ba.echo();

        return 0;
    }

If I don't have a complete brainfreeze at the moment, then (x && true) should
be identical to (x) and (x || false) should be identical to (x). The compiler
doesn't seem to notice that. Furthermore I don't understand why (requires x &&
true) is preferred over (requires x && true || false) and (requires x)

I'm using /opt/gcc-6/bin/g++ --version
  g++ (GCC) 6.0.0 20151213 (experimental)
  Copyright (C) 2015 Free Software Foundation, Inc.

Reply via email to