selftest: Work around GCC 4.2 PR33916 bug by optimizing the ctor [PR89494]
authorGustavo Romero <gromero@linux.ibm.com>
Wed, 15 Apr 2020 13:14:45 +0000 (15:14 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 15 Apr 2020 13:14:45 +0000 (15:14 +0200)
GCC 4.2 due to PR33916 miscompiles temp_dump_context ctor, because it doesn't
zero initialize the whole dump_context temporary on which it runs the static
get method and during destruction of the temporary an uninitialized pointer
is deleted.

More recent GCC versions properly zero initialize it and ideally optimize away
the construction/destruction of the temporary, as it isn't used for anything,
but there is no reason to create the temporary, static member functions can
be called without an associated object.

2020-04-15  Gustavo Romero  <gromero@linux.ibm.com>

PR bootstrap/89494
* dumpfile.c (selftest::temp_dump_context::temp_dump_context):
Don't construct a dump_context temporary to call static method.

gcc/ChangeLog
gcc/dumpfile.c

index 55f2e96732523818656158e4bdc96baf79519136..6148a8276c9a9677c167aedde5df0562fc8de161 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-15  Gustavo Romero  <gromero@linux.ibm.com>
+
+       PR bootstrap/89494
+       * dumpfile.c (selftest::temp_dump_context::temp_dump_context):
+       Don't construct a dump_context temporary to call static method.
+
 2020-04-15  Andrea Corallo  <andrea.corallo@arm.com>
 
        * config/aarch64/falkor-tag-collision-avoidance.c
index 468ffab6ccebe6bdf29a8063aec8a090121e4ca0..e392ecf307c4ad9814016ea90dfc7bad40ac5d2c 100644 (file)
@@ -2076,7 +2076,7 @@ temp_dump_context::temp_dump_context (bool forcibly_enable_optinfo,
                                      bool forcibly_enable_dumping,
                                      dump_flags_t test_pp_flags)
 : m_context (),
-  m_saved (&dump_context ().get ())
+  m_saved (&dump_context::get ())
 {
   dump_context::s_current = &m_context;
   if (forcibly_enable_optinfo)