Skip to content

Crash with concepts in diagnoseWellFormedUnsatisfiedConstraintExpr #64723

Closed
@zyn0217

Description

@zyn0217
Contributor

The following code hits an assertion from diagnoseWellFormedUnsatisfiedConstraintExpr:

template <typename _Iterator> class normal_iterator {};

/// is_convertible
template <typename From, typename To> struct is_convertible {};

template <typename From, typename To>
inline constexpr bool is_convertible_v = is_convertible<From, To>::value;

template <typename From, typename To>
concept convertible_to = is_convertible_v<From, To>;

template <typename IteratorL, typename IteratorR>
  requires requires(IteratorL __lhs, IteratorR __rhs) {
    { __lhs == __rhs } -> convertible_to<bool>;
  }
constexpr bool operator==(normal_iterator<IteratorL> __lhs,
                          normal_iterator<IteratorR> __rhs) {
  return __lhs.base() == __rhs.base();
}

template <typename T> struct Vector {
  normal_iterator<T> begin() const { return {}; }
  normal_iterator<T> end() const { return {}; }
};

class Object;

void function(Vector<Object *> objects) { objects.begin() == objects.end(); }

https://clang.godbolt.org/z/evchKETWq

See clangd/clangd#1726 for analysis.

Activity

self-assigned this
on Aug 16, 2023
llvmbot

llvmbot commented on Aug 16, 2023

@llvmbot
Member

@llvm/issue-subscribers-clang-frontend

zyn0217

zyn0217 commented on Aug 16, 2023

@zyn0217
ContributorAuthor

This appears to be a duplicate of #64172, as my local patch would also resolve it.

zyn0217

zyn0217 commented on Aug 16, 2023

@zyn0217
ContributorAuthor
added this to the LLVM 17.0.X Release milestone on Aug 19, 2023
tru

tru commented on Aug 21, 2023

@tru
Collaborator

@AaronBallman is this something we should fix in 17.x? I see you added as a reviewer on the Phab diff.

llvmbot

llvmbot commented on Aug 21, 2023

@llvmbot
Member

@llvm/issue-subscribers-c-20

AaronBallman

AaronBallman commented on Aug 21, 2023

@AaronBallman
Collaborator

We've been asserting on that code since Clang 10.0: https://clang.godbolt.org/z/Y6drTe37z so it's not a regression. I don't think we need to block 17.x on a fix for this (esp because @erichkeane is still out for a bit longer, so we won't hear from the concepts code owner before putting out the next rc).

11 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @tru@AaronBallman@EugeneZelenko@llvmbot@zyn0217

      Issue actions

        Crash with concepts in diagnoseWellFormedUnsatisfiedConstraintExpr · Issue #64723 · llvm/llvm-project