Bug 86618

Summary: tree-vect-stmts.c:3340: ubsan error
Product: gcc Reporter: David Binderman <dcb314>
Component: cAssignee: Richard Sandiford <rsandifo>
Status: RESOLVED FIXED    
Severity: normal CC: rsandifo
Priority: P3    
Version: 8.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2018-07-23 00:00:00
Bug Depends on:    
Bug Blocks: 63426    

Description David Binderman 2018-07-21 06:58:28 UTC
The following C code 

register struct a *b asm("%r15");
struct a {
  double *c
} d() {
  (*b).c[1] = copysign(1, (*b).c[1]);
  (*b).c[0] = copysign(0, (*b).c[0]);
}

Seems to generate a new runtime error on a ubsan verison of gcc trunk

../results.262549.ubsan/bin/gcc
../results.262835.ubsan/bin/gcc
../../trunk/gcc/tree-vect-stmts.c:3340:19: runtime error: member access within n
ull pointer of type 'struct _loop_vec_info'

So the error seems to appeared between revisions 262549 and 262835.
Comment 1 David Binderman 2018-07-21 07:00:34 UTC
svn blame says

262589   rsandifo   vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
Comment 2 David Binderman 2018-07-21 07:02:07 UTC
gcc compiler flag -O3 required.
Comment 3 Martin Liška 2018-07-23 12:10:39 UTC
Confirmed.
Comment 4 Richard Sandiford 2018-07-24 18:08:50 UTC
Author: rsandifo
Date: Tue Jul 24 18:08:19 2018
New Revision: 262951

URL: https://gcc.gnu.org/viewcvs?rev=262951&root=gcc&view=rev
Log:
Avoid &LOOP_VINFO_MASKS for bb vectorisation (PR 86618)

r262589 introduced another instance of the bug fixed in r258131.

2018-07-23  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	PR tree-optimization/86618
	* tree-vect-stmts.c (vectorizable_call): Don't take the address
	of LOOP_VINFO_MASKS (loop_vinfo) when loop_vinfo is null.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-stmts.c
Comment 5 Richard Sandiford 2018-07-25 08:44:00 UTC
Fixed by r262951.