<div dir="ltr"><div dir="auto">Hi everyone,<div dir="auto">I am working on a patch that involves reinterpret_cast of pointer to member. Working on Godbolt, it seems that the casts don't always make sense. Take a look at <a href="https://godbolt.org/z/6E7aoK">https://godbolt.org/z/6E7aoK</a>.</div><div>Both c and cs are supposed to point to the same field. However, c has the wrong offset (12) while cs has the right offset (0). This can be seen from the return value also (returns 16 instead of the expected 29).</div><div>So my query is: are reinterpret_cast on pointer-to-member considered undefined behaviour? Because different optimisation levels give different answers (try -O2).</div><div>Warm regards,</div><div>Deep<br></div></div>
</div>