[Bug regression/21897] New: Segementation fault in fold_ternary
e9925248 at stud4 dot tuwien dot ac dot at
gcc-bugzilla@gcc.gnu.org
Fri Jun 3 09:13:00 GMT 2005
Example code:
#define vector64 __attribute__((vector_size(8)))
main(){
vector64 short c;
vector64 short a = {1, -1};
vector64 short b = {2, -2};
c = -a + b*b*(-1LL);
printf("result is %llx\n", (long long)c);
}
If it is compiled with -O3 a Segmentation fault happens.
GNU C version 4.1.0 20050603 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 4.1.0 20050302 (experimental).
GGC heuristics: --param ggc-min-expand=0 --param ggc-min-heapsize=0
gcc (GCC) 4.1.0 20050302 (experimental)
and later (at least till 20050501) can compile this file with -O3.
The fold of this expression causes the segmentation fault:
<bit_field_ref 0xb7f56118
type <integer_type 0xb7ef6438 short int public HI
size <integer_cst 0xb7eee318 constant invariant 16>
unit size <integer_cst 0xb7eee330 constant invariant 2>
align 16 symtab 0 alias set -1 precision 16 min <integer_cst 0xb7eee2b8
-32768> max <integer_cst 0xb7eee2e8 32767>
pointer_to_this <pointer_type 0xb7f069b4>>
arg 0 <vector_cst 0xb7f1d018
type <vector_type 0xb7f06b64 type <integer_type 0xb7ef6438 short int>
sizes-gimplified DI
size <integer_cst 0xb7eee540 constant invariant 64>
unit size <integer_cst 0xb7eee558 constant invariant 8>
align 64 symtab 0 alias set -1 nunits 4>
constant invariant
elt0: <integer_cst 0xb7f07bb8 constant invariant 1>
elt1: <integer_cst 0xb7f0a510 constant invariant -1>> arg 1
<integer_cst 0xb7eee318 16>
arg 2 <integer_cst 0xb7eee408 type <integer_type 0xb7ef6288 bit_size_type>
constant invariant 32>>
The problem is, that fold_ternary wants to access the third element of the
constant vector, which is not present.
The cause of this is, that fold_ternary fails, if it an element of the vector is
not initialized.
The change seem to be done by
2005-06-01 Jakub Jelinek <jakub@redhat.com>
* fold-const.c (fold_ternary): Optimize BIT_FIELD_REF of VECTOR_CST.
Replacing (in fold_ternary case BIT_FIELD_REF:)
while (idx-- > 0)
elements = TREE_CHAIN (elements);
return TREE_VALUE (elements);
with
while (idx-- > 0 && elements)
elements = TREE_CHAIN (elements);
if(elements)
return TREE_VALUE (elements);
else return build_int_cst_type(type,0);
should solve the problem.
--
Summary: Segementation fault in fold_ternary
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: regression
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: e9925248 at stud4 dot tuwien dot ac dot at
CC: gcc-bugs at gcc dot gnu dot org,jakub at redhat dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21897
More information about the Gcc-bugs
mailing list