[Bug c++/85710] New: Enabling memset-elt-size warning causes ICE on memset of template member array
jwyatt at feralinteractive dot com
gcc-bugzilla@gcc.gnu.org
Wed May 9 12:29:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85710
Bug ID: 85710
Summary: Enabling memset-elt-size warning causes ICE on memset
of template member array
Product: gcc
Version: 8.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jwyatt at feralinteractive dot com
Target Milestone: ---
The memset-elt-size warning causes an internal compiler error when compiling:
#include <cstring>
template <typename T> struct A { int a; };
template <typename T>
class E
{
public:
void Clear();
private:
A<T> mA[2];
};
template<typename T>
void E<T>::Clear()
{
memset(mA, 0, sizeof(int)*2);
}
It does not cause an ICE if mA is not an array, or is an array of size 1. It
does not cause an ICE if using memset(mA, 0, sizeof(mA)); or memset(&mA[0], 0,
sizeof(int)*2);
The code causes an ICE when compiled with:
g++ -Wmemset-elt-size test.cpp
It does not cause an ICE when compiled with:
g++ -Wall -Wextra -Wno-memset-elt-size
Reproduces in:
g++ (GCC) 8.1.1 20180502 (Red Hat 8.1.1-1)
Configured with: ../gcc-8.1.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu --enable-languages=c,c++,fortran
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto
--enable-plugins --enable-threads=posix --with-pkgversion=GCC-Explorer-Build
Thread model: posix
gcc version 8.1.0 (GCC-Explorer-Build)
Configured with: ../gcc-trunk-20180508/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu --enable-languages=c,c++,fortran
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto
--enable-plugins --enable-threads=posix --with-pkgversion=GCC-Explorer-Build
Thread model: posix
gcc version 9.0.0 20180508 (experimental) (GCC-Explorer-Build)
Does not reproduce in:
Configured with: ../gcc-7.3.0/configure --prefix /root/staging
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--disable-bootstrap --enable-multiarch --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --enable-clocale=gnu
--enable-languages=c,c++,fortran --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix
--with-pkgversion=GCC-Explorer-Build
Thread model: posix
gcc version 7.3.0 (GCC-Explorer-Build)
More information about the Gcc-bugs
mailing list