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++/67038] New: [c++-concepts] Viable function template despite unsatisfied constraints


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

            Bug ID: 67038
           Summary: [c++-concepts] Viable function template despite
                    unsatisfied constraints
           Product: gcc
           Version: c++-concepts
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Casey at Carter dot net
  Target Milestone: ---

Created attachment 36077
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36077&action=edit
Preprocessed test case

r226205 fails to compile this correct program:

#include <stl2/iterator.hpp>

template <stl2::WeakOutputIterator<int> I>
  requires !stl2::WeakInputIterator<I>()
constexpr bool dispatch() { return false; }

template <stl2::WeakInputIterator I>
constexpr bool dispatch() { return true; }

template <stl2::WeakOutputIterator<int> I>
constexpr bool is_weak_out() { return true; }

template <stl2::WeakInputIterator I>
constexpr bool is_weak_in() { return true; }

int main() {
  static_assert(is_weak_out<int*>());
  static_assert(is_weak_in<int*>());
  static_assert(dispatch<int*>());
}

with error:

~/concept-gcc/bin/g++ -std=gnu++1z -I ~/cmcstl2/include -I
~/cmcstl2/meta/include foo.cpp -c
foo.cpp: In function âint main()â:
foo.cpp:19:32: error: call of overloaded âdispatch()â is ambiguous
   static_assert(dispatch<int*>());
                                ^
foo.cpp:5:16: note: candidate: constexpr bool dispatch() [with I = int*]
 constexpr bool dispatch() { return false; }
                ^
foo.cpp:8:16: note: candidate: constexpr bool dispatch() [with I = int*]
 constexpr bool dispatch() { return true; }
                ^

The compiler apparently considers both overloads of dispatch to be viable
despite that the first overload's constraint !stl2::WeakInputIterator<I>() is
clearly not satisfied when I is int*.

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