This is the mail archive of the gcc-bugs@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]

[Bug sanitizer/66977] -fsanitize=shift may introduce uninitialized variables


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66977

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Another approach would be

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 2ed43be..41f54ac 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3288,6 +3288,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr,
tree function,
       idx = build1 (NOP_EXPR, vtable_index_type, e3);
       switch (TARGET_PTRMEMFUNC_VBIT_LOCATION)
    {
+   int flag_sanitize_save;
    case ptrmemfunc_vbit_in_pfn:
      e1 = cp_build_binary_op (input_location,
                   BIT_AND_EXPR, idx, integer_one_node,
@@ -3303,9 +3304,12 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr,
tree function,
      e1 = cp_build_binary_op (input_location,
                   BIT_AND_EXPR, delta, integer_one_node,
                   complain);
+     flag_sanitize_save = flag_sanitize;
+     flag_sanitize = 0;
      delta = cp_build_binary_op (input_location,
                      RSHIFT_EXPR, delta, integer_one_node,
                      complain);
+     flag_sanitize = flag_sanitize_save;
      if (delta == error_mark_node)
        return error_mark_node;
      break;


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