public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/115172] Invalid -fsanitize=bool sanitization of variable from named address space
Date: Tue, 21 May 2024 10:16:00 +0000	[thread overview]
Message-ID: <bug-115172-4-lBBKSrQgsw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-115172-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That said,
--- gcc/ubsan.cc.jj     2024-03-22 09:23:37.695296775 +0100
+++ gcc/ubsan.cc        2024-05-21 12:10:24.261454107 +0200
@@ -1776,13 +1776,17 @@ instrument_bool_enum_load (gimple_stmt_i
       || TREE_CODE (gimple_assign_lhs (stmt)) != SSA_NAME)
     return;

+  addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (rhs));
+  if (as != TYPE_ADDR_SPACE (utype))
+    utype = build_qualified_type (utype, TYPE_QUALS (utype)
+                                        | ENCODE_QUAL_ADDR_SPACE (as));
   bool ends_bb = stmt_ends_bb_p (stmt);
   location_t loc = gimple_location (stmt);
   tree lhs = gimple_assign_lhs (stmt);
   tree ptype = build_pointer_type (TREE_TYPE (rhs));
   tree atype = reference_alias_ptr_type (rhs);
   gimple *g = gimple_build_assign (make_ssa_name (ptype),
-                                 build_fold_addr_expr (rhs));
+                                  build_fold_addr_expr (rhs));
   gimple_set_location (g, loc);
   gsi_insert_before (gsi, g, GSI_SAME_STMT);
   tree mem = build2 (MEM_REF, utype, gimple_assign_lhs (g),
seems to fix that.  But wonder how many of the other ~180 spots that create
MEM_REFs don't need similar fixes.

  parent reply	other threads:[~2024-05-21 10:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21  9:33 [Bug sanitizer/115172] New: " ubizjak at gmail dot com
2024-05-21 10:05 ` [Bug sanitizer/115172] " jakub at gcc dot gnu.org
2024-05-21 10:16 ` jakub at gcc dot gnu.org [this message]
2024-05-21 10:20 ` ubizjak at gmail dot com
2024-05-21 10:35 ` jakub at gcc dot gnu.org
2024-05-21 14:21 ` ubizjak at gmail dot com
2024-05-21 17:19 ` pchelkin at ispras dot ru
2024-05-21 21:08 ` jakub at gcc dot gnu.org
2024-05-22  7:13 ` cvs-commit at gcc dot gnu.org
2024-05-22  7:19 ` cvs-commit at gcc dot gnu.org
2024-05-22  7:35 ` cvs-commit at gcc dot gnu.org
2024-05-22 11:11 ` jakub at gcc dot gnu.org
2024-05-28 17:09 ` cvs-commit at gcc dot gnu.org
2024-05-28 17:09 ` cvs-commit at gcc dot gnu.org
2024-05-28 17:11 ` ubizjak at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-115172-4-lBBKSrQgsw@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).