[patch] Fix tree-optimization/91169

Eric Botcazou ebotcazou@adacore.com
Thu Aug 1 08:27:00 GMT 2019


Hi,

this fixes the cd2a31a regression in the ACATS testsuite on 32-bit targets 
introduced by the recent change to get_array_ctor_element_at_index:

	* fold-const.h (get_array_ctor_element_at_index): Adjust.
	* fold-const.c (get_array_ctor_element_at_index): Add
	ctor_idx output parameter informing the caller where in
	the constructor the element was (not) found.  Add early exit
	for when the ctor is sorted.

This change overlooks that the index can wrap around during the traversal of 
the CONSTRUCTOR and therefore causes the function to return bogus values as 
soon as this happens.  Moreover, given this chunk of added code:

      else if (in_gimple_form)
	/* We're past the element we search for.  Note during parsing
	   the elements might not be sorted.
	   ???  We should use a binary search and a flag on the
	   CONSTRUCTOR as to whether elements are sorted in declaration
	   order.  */
	break;

I would respectfully suggest that the author thinks about redoing things from 
scratch here.  In the meantime, the attached patch kludges around the issue.

Tested on x86_64-suse-linux, OK for the mainline?


2019-08-01  Eric Botcazou  <ebotcazou@adacore.com>

	PR tree-optimization/91169
	* fold-const.c (get_array_ctor_element_at_index): Remove early exit and
	do not return a bogus ctor_idx when the index wraps around.

-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr91169.diff
Type: text/x-patch
Size: 2657 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190801/5c23b7b8/attachment.bin>


More information about the Gcc-patches mailing list