Re: [eigen] gcc 4.2.4 warning on type-punned pointers |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] gcc 4.2.4 warning on type-punned pointers
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 19 Aug 2010 14:47:52 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=/nj115FLqXQMjdTguT4ayYjU6wAJWcOZhyT5STY63bA=; b=g2YSA5o2Kp8vXXsxlJV+vV9HDFidf+bfrNDq9Nr15a9n8bxphQ0ZmxOEQF9aUVhFtb CVX3DpH6EpTPTq8YEQ4EiktjUrf506JrB89lMVhkbg9p8zFxVs4YpMD0TrJegYqtyFvF fmEUTOPXM8/8AP6aSCmw5a2lHQKxvRBfbKSfs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=IWRIpfSpqu4UIng5RTMwatx0bsMgYeeKY6IehwyztJvPNN9JuSEFV8my5cjX6CIVG8 3zPPkhadNKJGlbwCVXp82pqlEbLwMB/VoTtWIYx4dq2Kvlmf/sGWiNGcfHp+uII92W5S eCyRToVUcdx6MWAHKtkprGmESF7zjAcffLMe8=
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
>
>
>
>