https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125386
Bug ID: 125386
Summary: Diagnostics for failed cast from *this to void*
highlight wrong *this
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
struct foo {
void bar(void* src)
{
__builtin_memcpy(*this, src, sizeof(*this));
}
};
No flags needed. https://godbolt.org/z/35Te6co43
Result:
<source>: In member function 'void foo::bar(void*)':
<source>:4:45: error: cannot convert 'foo' to 'void*'
4 | __builtin_memcpy(*this, src, sizeof(*this));
| ~^~~~~~
| |
| foo
<built-in>: note: initializing argument 1 of 'void* __builtin_memcpy(void*,
const void*, long unsigned int)'
Expected: Highlight the *this in argument 1, not argument 3. (Rejecting this
input is correct, I should've removed the asterisk from argument 1.)