Displaying 5 results from an estimated 5 matches for "aligned_union".
2018 Aug 14
3
GCC 5 and -Wstrict-aliasing in JSON.h
On 08/12/2018 02:19 PM, Kim Gräsman wrote:
> I still feel a little uncomfortable, because I think Jonathan makes an
> excellent point -- if GCC thinks there's a strict-aliasing violation
> (whether the standard agrees or not) and classifies this as undefined
> behavior, we might invoke the optimizers wrath. The warning is a nice
> hint that this could happen.
Indeed. And
2018 Aug 17
0
GCC 5 and -Wstrict-aliasing in JSON.h
...> As it turns out, Union is not a union ¯\_(ツ)_/¯. (I thought it was, up
> > until this point.)
> >
> > It's a template producing a char array suitably aligned for any number
> > of mutually exclusive types, much like
> > https://en.cppreference.com/w/cpp/types/aligned_union.
> >
> > I can't tell if that makes the waters less dangerous, but there's an
> > invariant for this code that it only reinterpret_casts out Ts from the
> > char buffer that it has previously put in there using placement new.
>
> So I think GCC is wrong here....
2018 Aug 14
1
GCC 5 and -Wstrict-aliasing in JSON.h
...he appropriate type?
>
> As it turns out, Union is not a union ¯\_(ツ)_/¯. (I thought it was, up
> until this point.)
>
> It's a template producing a char array suitably aligned for any number
> of mutually exclusive types, much like
> https://en.cppreference.com/w/cpp/types/aligned_union.
>
> I can't tell if that makes the waters less dangerous, but there's an
> invariant for this code that it only reinterpret_casts out Ts from the
> char buffer that it has previously put in there using placement new.
> As far as I can tell, that should be safe. The local con...
2018 Aug 10
4
GCC 5 and -Wstrict-aliasing in JSON.h
在 2018-08-10 06:20, Kim Gräsman 写道:
> On Fri, Aug 10, 2018 at 12:02 AM, Jonathan Wakely <jwakely.gcc at gmail.com>
> wrote:
>>
>> If GCC 4.9.3 thinks there's an aliasing violation it might
>> misoptimise. It doesn't matter if it's right or not, it matters if it
>> treats the code as undefined or not.
>>
>> And apparently GCC does think
2018 Aug 12
4
GCC 5 and -Wstrict-aliasing in JSON.h
I did some more extensive testing and found that all GCCs older than 7
trigger the warning, but only if CMAKE_BUILD_TYPE=Release (which I
guess indicates optimizations are enabled).
There's a patch up for disabling the warning here:
https://reviews.llvm.org/D50607.
I still feel a little uncomfortable, because I think Jonathan makes an
excellent point -- if GCC thinks there's a