frederick-vs-ja wrote:

Looks like there're still some other false-positive cases 
(https://godbolt.org/z/1G9WPn9de):

```C++
constexpr bool same_address(const int &a, const int &b) { return &a == &b; }
constexpr int next_element(const int &p) { return (&p)[2]; }

struct Base {};
struct Derived : Base { int n; };
constexpr int get_derived_member(const Base& b) { return static_cast<const 
Derived&>(b).n; }

struct PolyBase {
  constexpr virtual int get() const { return 0; }
};
struct PolyDerived : PolyBase {
  constexpr int get() const override { return 1; }
};
constexpr int virtual_call(const PolyBase& b) { return b.get(); }

constexpr int arr[3]{0, 1, 2};
static_assert(same_address(arr[1], arr[1]));
static_assert(next_element(arr[0]) == 2);

static_assert(get_derived_member(Derived{}) == 0);
static_assert(virtual_call(PolyDerived{}) == 1);
```

https://github.com/llvm/llvm-project/pull/149227
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to