From: Jakub Jelinek Date: Mon, 21 Jan 2019 19:53:04 +0000 (+0100) Subject: re PR sanitizer/88901 (ICE when using -fsanitize=pointer-compare) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=52e6797044fc8e5281d862339f4c27988017557d;p=gcc.git re PR sanitizer/88901 (ICE when using -fsanitize=pointer-compare) PR sanitizer/88901 * typeck.c (cp_build_binary_op): Don't instrument SANITIZE_POINTER_COMPARE if processing_template_decl. (pointer_diff): Similarly for SANITIZE_POINTER_SUBTRACT. * g++.dg/asan/pr88901.C: New test. From-SVN: r268122 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4292930daf3..e5ce94c75e8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-01-21 Jakub Jelinek + + PR sanitizer/88901 + * typeck.c (cp_build_binary_op): Don't instrument + SANITIZE_POINTER_COMPARE if processing_template_decl. + (pointer_diff): Similarly for SANITIZE_POINTER_SUBTRACT. + 2019-01-18 Jason Merrill PR c++/88875 - error with explicit list constructor. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 47e407d1faa..ec722a36035 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5233,6 +5233,7 @@ cp_build_binary_op (const op_location_t &location, } if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE) + && !processing_template_decl && sanitize_flags_p (SANITIZE_POINTER_COMPARE)) { op0 = save_expr (op0); @@ -5650,7 +5651,8 @@ pointer_diff (location_t loc, tree op0, tree op1, tree ptrtype, else inttype = restype; - if (sanitize_flags_p (SANITIZE_POINTER_SUBTRACT)) + if (!processing_template_decl + && sanitize_flags_p (SANITIZE_POINTER_SUBTRACT)) { op0 = save_expr (op0); op1 = save_expr (op1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a483214c55..ba5285fc710 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-21 Jakub Jelinek + + PR sanitizer/88901 + * g++.dg/asan/pr88901.C: New test. + 2019-01-21 Tamar Christina * g++.dg/vect/simd-clone-7.cc: Fix assembler scan. diff --git a/gcc/testsuite/g++.dg/asan/pr88901.C b/gcc/testsuite/g++.dg/asan/pr88901.C new file mode 100644 index 00000000000..fa5d949fe3a --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr88901.C @@ -0,0 +1,13 @@ +// PR sanitizer/88901 +// { dg-do compile } +// { dg-options "-fsanitize=address -fsanitize=pointer-compare" } + +template +struct A { + void foo() { + auto d = [](char *x, char *y) { + for (char *p = x; p + sizeof(T) <= y; p += sizeof(T)) + reinterpret_cast(p)->~T(); + }; + } +};