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++/77601] New: error: cannot convert 'is_same<int, Z>' to 'const bool' in initialization


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

            Bug ID: 77601
           Summary: error: cannot convert 'is_same<int, Z>' to 'const
                    bool' in initialization
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lh_mouse at 126 dot com
  Target Milestone: ---

The following code chokes GCC:

    template<typename T, typename U>
    struct is_same {
        constexpr operator bool() const noexcept {
            return false;
        }
    };
    template<typename T>
    struct is_same<T, T> {
        constexpr operator bool() const noexcept {
            return true;
        }
    };

    template<typename Z>
    void foo(Z){
        // This works with clang++ but does not with g++.
        constexpr bool b1 = is_same<int, Z>{};

        // This works with both.
        constexpr bool b2 = is_same<int, Z>();
    }

    int main(){
        foo(1);
        // This works with both, too.

        constexpr bool b3 = is_same<int, int>();
    }

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