Re: [eigen] gcc 4.2.4 warning on type-punned pointers

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


this cannot be fixed using c++ cast operators. On the other hand, the following:

return std::complex<double>(res[0],res[1])

is safe and the compiler smart enough to avoid the copy.

I've just committed this fix.

gael

On Tue, Aug 17, 2010 at 6:05 PM, Manoj Rajagopalan <rmanoj@xxxxxxxxx> wrote:
>
> I see this only in release build. The exact error is as follows (just pulled
> in latest sources from hg):
>
> /usr/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h: In
> function ‘typename Eigen::ei_unpacket_traits<T>::type Eigen::ei_pfirst(const
> Packet&) [with Packet = Eigen::Packet1cd]’:
> /usr/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h:311: warning:
> dereferencing type-punned pointer will break strict-aliasing rules
>
>
>    My command-line flags are (mind the -march option):
>
>    -Wall -Wmissing-include-dirs -Wswitch-default -Wunused-parameter -Wextra -Wconversion
>    -march=pentium4 -g0 -O3 -msse2 -mfpmath=sse -ftree-vectorize  -fgcse-sm -fgcse-las
>    -fgcse-after-reload -fipa-pta  -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon
>    -ftracer -funroll-loops -fvariable-expansion-in-unroller -fprefetch-loop-arrays -fno-math-errno
>    -ffinite-math-only -fno-trapping-math -fno-signaling-nans -DEIGEN_NO_AUTOMATIC_RESIZING
>
> Thanks,
> Manoj
>
>
> On Friday 13 August 2010 12:23:56 am Benoit Jacob wrote:
>> 2010/8/12 Manoj Rajagopalan <rmanoj@xxxxxxxxx>:
>> > Hi,
>> >
>> >  I'm seeing this warning
>>
>> what warning? please paste it all here. i can't reproduce with gcc 4.4
>> and usually gcc only gets more pedantic with time.
>>
>> Benoit
>>
>> > from Complex.h, line 311 where a real[2] is cast as
>> > complex* in C-style. I am tempted to submit a correction with static_cast
>> > or reinterpret_cast instead but I'd first like to ask if this is likely
>> > to cause issues related to alignment or otherwise.
>> >
>> > thanks,
>> > Manoj
>
>
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/