public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR106062-ice)] c++: properly initialize UBSAN built-ins
@ 2022-06-23 12:45 Martin Liska
0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2022-06-23 12:45 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8aaba12b4668d0ebc8c5d039a82b17694e94b56d
commit 8aaba12b4668d0ebc8c5d039a82b17694e94b56d
Author: Martin Liska <mliska@suse.cz>
Date: Thu Jun 23 14:43:50 2022 +0200
c++: properly initialize UBSAN built-ins
PR c++/106062
gcc/ChangeLog:
* ubsan.cc (sanitize_unreachable_fn): Change order of calls
in order to initialize UBSAN built-ins.
gcc/testsuite/ChangeLog:
* gfortran.dg/ubsan/pr106062.f90: New test.
Diff:
---
gcc/testsuite/gfortran.dg/ubsan/pr106062.f90 | 11 +++++++++++
gcc/ubsan.cc | 3 ++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/gfortran.dg/ubsan/pr106062.f90 b/gcc/testsuite/gfortran.dg/ubsan/pr106062.f90
new file mode 100644
index 00000000000..879a67eb749
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/ubsan/pr106062.f90
@@ -0,0 +1,11 @@
+! PR c++/106062
+! { dg-do compile }
+! { dg-options "-O2 -fsanitize=undefined" }
+
+call test (reshape ((/ 'a', 'b', 'c', 'd' /), (/ 2, 2 /)))
+contains
+ subroutine test (a)
+ character (*), dimension (:, :) :: a
+ if (len (a) .ne. 1) STOP
+ end
+end
diff --git a/gcc/ubsan.cc b/gcc/ubsan.cc
index f15026872a1..b6c4301dfaf 100644
--- a/gcc/ubsan.cc
+++ b/gcc/ubsan.cc
@@ -654,9 +654,10 @@ sanitize_unreachable_fn (tree *data, location_t loc)
}
else if (san)
{
- fn = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE);
+ /* Call ubsan_create_data first as it initializes SANITIZER built-ins. */
*data = ubsan_create_data ("__ubsan_unreachable_data", 1, &loc,
NULL_TREE, NULL_TREE);
+ fn = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE);
*data = build_fold_addr_expr_loc (loc, *data);
}
else
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-23 12:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 12:45 [gcc(refs/users/marxin/heads/PR106062-ice)] c++: properly initialize UBSAN built-ins Martin Liska
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).