C++ Logo

sg12

Advanced search

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

From: Lawrence Crowl <Lawrence_at_[hidden]>
Date: Thu, 25 Jul 2013 13:56:12 -0700
On 7/25/13, Howard Hinnant <howard.hinnant_at_[hidden]> wrote:
> It was this SO question that started this thread:
>
> http://stackoverflow.com/q/17789928/576911
>
> 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:
>
> http://stackoverflow.com/a/17790026/576911
>
> does not break the aliasing rules, or otherwise invoke undefined behavior?

I believe so.

>
> Thanks,
> Howard
>
> _______________________________________________
> ub mailing list
> ub_at_[hidden]
> http://www.open-std.org/mailman/listinfo/ub
>


-- 
Lawrence Crowl

Received on 2013-07-25 22:56:28