Issue 165234
Summary [clang][bytecode] Call to consteval function is not a constant _expression_ when calling a virtual method
Labels clang
Assignees
Reporter BobIsOnFire
    ```cpp
struct A {
    constexpr virtual void call(int) = 0;

    constexpr void call2() { call(0); }
};

struct B : A {
    constexpr void call(int) override {}
};

consteval void check() {
    B b;
    b.call2();
}

int main() { check(); }
```

```
<source>:16:14: error: call to consteval function 'check' is not a constant _expression_
   16 | int main() { check(); }
 |              ^
<source>:4:30: note: pure virtual function 'A::call' called
    4 |     constexpr void call2() { call(0); }
      | ^
<source>:13:5: note: in call to 'b.call2()'
   13 | b.call2();
      |     ^~~~~~~~~
<source>:16:14: note: in call to 'check()'
   16 | int main() { check(); }
      | ^~~~~~~
<source>:2:28: note: declared here
    2 |     constexpr virtual void call(int) = 0;
      |                            ^
1 error generated.
Compiler returned: 1
```

https://godbolt.org/z/h4hdW9ars
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to