diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-02-26 15:37:45 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-02-26 15:37:45 +0100 |
commit | ff9fccdcb5118d494bba801038a1c334bf2e38fd (patch) | |
tree | a3127c41450f5dbb9df32332493546c6bf2fa3f2 /gcc | |
parent | 7518398dce1d913e01899d3aa52caec50e6efb4f (diff) | |
download | gcc-ff9fccdcb5118d494bba801038a1c334bf2e38fd.zip gcc-ff9fccdcb5118d494bba801038a1c334bf2e38fd.tar.gz gcc-ff9fccdcb5118d494bba801038a1c334bf2e38fd.tar.bz2 |
re PR bootstrap/84405 (Fails to bootstrap with GCC 4.1.2, GCC 4.2.4)
PR bootstrap/84405
* vec.h (vec_default_construct): For BROKEN_VALUE_INITIALIZATION use
memset and value initialization afterwards.
From-SVN: r257989
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/vec.h | 19 |
2 files changed, 21 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7a070c5..ebbc25b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-02-26 Jakub Jelinek <jakub@redhat.com> + + PR bootstrap/84405 + * vec.h (vec_default_construct): For BROKEN_VALUE_INITIALIZATION use + memset and value initialization afterwards. + 2018-02-26 Christophe Lyon <christophe.lyon@linaro.org> * Makefile.in (lto-wrapper): Use ALL_LINKERFLAGS. @@ -490,12 +490,23 @@ template <typename T> inline void vec_default_construct (T *dst, unsigned n) { -#ifndef BROKEN_VALUE_INITIALIZATION - for ( ; n; ++dst, --n) - ::new (static_cast<void*>(dst)) T (); -#else +#ifdef BROKEN_VALUE_INITIALIZATION + /* Versions of GCC before 4.4 sometimes leave certain objects + uninitialized when value initialized, though if the type has + user defined default ctor, that ctor is invoked. As a workaround + perform clearing first and then the value initialization, which + fixes the case when value initialization doesn't initialize due to + the bugs and should initialize to all zeros, but still allows + vectors for types with user defined default ctor that initializes + some or all elements to non-zero. If T has no user defined + default ctor and some non-static data members have user defined + default ctors that initialize to non-zero the workaround will + still not work properly; in that case we just need to provide + user defined default ctor. */ memset (dst, '\0', sizeof (T) * n); #endif + for ( ; n; ++dst, --n) + ::new (static_cast<void*>(dst)) T (); } /* Copy-construct N elements in DST from *SRC. */ |