This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[match-and-simplify] set simplify::capture_max to 0 if pattern contains no captures
- From: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- To: rguenther at suse dot de, gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Dec 2014 02:16:26 +0530
- Subject: [match-and-simplify] set simplify::capture_max to 0 if pattern contains no captures
- Authentication-results: sourceware.org; auth=none
Caused segfault for pattern containing no captures at:
info.safe_grow_cleared(capture_max + 1); in capture_info::capture_info
artificial test-case:
(define_predicates integer_zerop)
(simplify
(bit_not integer_zerop)
{ build_zero_cst (type); })
* genmatch.c
(simplify::simplify): Set simplify::capture_max to 0 if pattern
contains no captures.
Thanks,
Prathamesh
Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c (revision 218664)
+++ gcc/genmatch.c (working copy)
@@ -576,7 +576,7 @@
: match (match_), match_location (match_location_),
result (result_), result_location (result_location_),
ifexpr_vec (ifexpr_vec_), for_vec (for_vec_),
- capture_ids (capture_ids_), capture_max (capture_ids_->elements () - 1) {}
+ capture_ids (capture_ids_), capture_max (capture_ids_->elements () ? capture_ids_->elements () - 1 : 0) {}
/* The expression that is matched against the GENERIC or GIMPLE IL. */
operand *match;