Including Eigen/Dense from eigen 3.4.0 gives warnings when building with GCC 11 for aarch64
Summary
Including Eigen/Dense from 3.4.0 and building for aarch64 with GCC 11 and -Wall enabled gives compiler warnings.
Environment
- Operating System : Yocto/OpenEmbedded master (upcoming Honister release)
- Architecture : aarch64
- Eigen Version : 3.4.0
- Compiler Version : GCC 11.2
- Compile Flags : -Wall
- Vector Extension : NEON
Minimal Example
#include <Eigen/Dense>
int
main(int argc __attribute__ ((__unused__)), char* argv[] __attribute__ ((__unused__)))
{
return 0;
}
Steps to reproduce
I use the aarch64 compiler built with Yocto, but I assume any aarch64-*-g++ should do.
- aarch64-poky-linux-g++ -Wall -I eigen-test.cc -o eigen-test
What is the current bug behavior?
There are compiler warnings due to -Wclass-memaccess.
What is the expected correct behavior?
It should compile without warnings.
Warning Messages
In file included from eigen/Eigen/Core:214,
from eigen/Eigen/Dense:1,
from eigen-test.cc:1:
eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function 'Packet Eigen::internal::pload(const typename Eigen::internal::unpacket_traits<T>::type*) [with Packet = Eigen::internal::eigen_packet_wrapper<int, 2>; typename Eigen::internal::unpacket_traits<T>::type = signed char]':
eigen/Eigen/src/Core/arch/NEON/PacketMath.h:1671:9: warning: 'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'Eigen::internal::Packet4c' {aka 'struct Eigen::internal::eigen_packet_wrapper<int, 2>'} from an array of 'const int8_t' {aka 'const signed char'} [-Wclass-memaccess]
1671 | memcpy(&res, from, sizeof(Packet4c));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from eigen/Eigen/Core:172,
from eigen/Eigen/Dense:1,
from eigen-test.cc:1:
eigen/Eigen/src/Core/GenericPacketMath.h:159:8: note: 'Eigen::internal::Packet4c' {aka 'struct Eigen::internal::eigen_packet_wrapper<int, 2>'} declared here
159 | struct eigen_packet_wrapper
| ^~~~~~~~~~~~~~~~~~~~
In file included from eigen/Eigen/Core:214,
from eigen/Eigen/Dense:1,
from eigen-test.cc:1:
eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function 'Packet Eigen::internal::ploadu(const typename Eigen::internal::unpacket_traits<T>::type*) [with Packet = Eigen::internal::eigen_packet_wrapper<int, 2>; typename Eigen::internal::unpacket_traits<T>::type = signed char]':
eigen/Eigen/src/Core/arch/NEON/PacketMath.h:1716:9: warning: 'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'Eigen::internal::Packet4c' {aka 'struct Eigen::internal::eigen_packet_wrapper<int, 2>'} from an array of 'const int8_t' {aka 'const signed char'} [-Wclass-memaccess]
1716 | memcpy(&res, from, sizeof(Packet4c));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from eigen/Eigen/Core:172,
from eigen/Eigen/Dense:1,
from eigen-test.cc:1:
eigen/Eigen/src/Core/GenericPacketMath.h:159:8: note: 'Eigen::internal::Packet4c' {aka 'struct Eigen::internal::eigen_packet_wrapper<int, 2>'} declared here
159 | struct eigen_packet_wrapper
| ^~~~~~~~~~~~~~~~~~~~
Anything else that might help
It builds without warnings with 3.3.9.
Using git bisect, I have determined that the problem was introduced with commit 4b9ecf29 (NEON: Added int8_t and uint8_t packet math).