C++ Logo


Advanced search

Re: [ub] Type punning to avoid copying (was: unions and undefined behavior)

From: Howard Hinnant <howard.hinnant_at_[hidden]>
Date: Thu, 25 Jul 2013 10:53:20 -0400
It was this SO question that started this thread:


I'm curious: The accepted answer uses memcpy and the claim is that this is a correct answer to the question. That is it does not exhibit undefined behavior. My current understanding is that I agree with this answer. But I wanted to check here. Do people here agree that:


does not break the aliasing rules, or otherwise invoke undefined behavior?


Received on 2013-07-25 16:53:23