79676564

Date: 2025-06-23 17:34:39
Score: 0.5
Natty:
Report link

The problem is that A is trivially copyable (memcpy works fine), but it's definitely not trivially relocatable. After copying, b.pn still points to a.n instead of b.n, which breaks the whole point of relocation - the new object should be independent.

I think when the proposal author said "trivially copyable implies trivially relocatable", they were speaking practically rather than formally. In most real code, trivially copyable types don't have these self-referential pointer issues. Standard library types are designed to avoid this trap.

But technically? No, the implication doesn't hold. Your struct proves it. A type can be safely memcpy'd without being safely relocated.

The distinction matters because:

Your example passes the first test but fails the second. So while the rule works as a heuristic for most code, it's not a formal guarantee.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Mohammad Aman