This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, IPA] Check pointer for 0 before use in `get_odr_type`


Hello,
Looks like `get_odr_type ()` contains code which dereferences
pointer before check it for zero. I moved the line under the check.

Bootstrap/regtest on x?86|x86_64 in progress.

Is it ok for trunk if pass?

gcc/
	* gcc/ipa-devirt.c (get_odr_type): Check odr_types_ptr for
	zero before dereferencing it.

--
Thanks, K

commit 9b822dfb4db14ce762a8d55cf76c677f3fae04bc
Author: Kirill Yukhin <kirill.yukhin@gmail.com>
Date:   Fri Sep 2 23:40:55 2016 +0300

    Access odr_type only if odr_type_ptr is not 0.

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 2cf018b..cca912c 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -2132,12 +2132,14 @@ get_odr_type (tree type, bool insert)
     }
   else if (base_id > val->id)
     {
-      odr_types[val->id] = 0;
       /* Be sure we did not recorded any derived types; these may need
         renumbering too.  */
       gcc_assert (val->derived_types.length() == 0);
       if (odr_types_ptr)
-       val->id = odr_types.length ();
+       {
+         odr_types[val->id] = 0;
+         val->id = odr_types.length ();
+       }
       vec_safe_push (odr_types_ptr, val);
     }
   return val;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]