https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113629
Bug ID: 113629
Summary: 'deducing this' does not work with conversion
operators
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
It seems that GCC's deducing this implementation has some issues with derived
classes that inherit from a base class that has conversion operators:
struct Base {
operator int(this auto&&) {
return 42;
}
};
struct Derived : Base {};
int main() {
Derived derived;
return static_cast<int>(derived);
}
GCC rejects the above code with:
<source>:11:10: error: invalid 'static_cast' from type 'Derived' to type 'int'
11 | return static_cast<int>(derived);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
which seems wrong.