[Bug fortran/80361] [5/6/7 Regression] bogus recursive call to nonrecursive procedure with -fcheck=recursion

2017-04-12 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80361

--- Comment #19 from Thomas Koenig  ---
(In reply to janus from comment #16)
> This seems to be sufficient to fix the runtime error on the reduced test
> case in comment #13:
> 
> 
> Index: gcc/fortran/class.c
> ===
> --- gcc/fortran/class.c   (revision 246822)
> +++ gcc/fortran/class.c   (working copy)
> @@ -1613,6 +1613,7 @@ generate_finalization_wrapper (gfc_symbol *derived
>final->attr.flavor = FL_PROCEDURE;
>final->attr.function = 1;
>final->attr.pure = 0;
> +  final->attr.recursive = 1;
>final->result = final;
>final->ts.type = BT_INTEGER;
>final->ts.kind = 4;

Simple enough to be obvious :-)

Pre-approved.

[Bug rtl-optimization/80343] [7 Regression] ICE in extract_constrain_insn, at recog.c:2213 (error: insn does not satisfy its constraints)

2017-04-12 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80343

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P2
 CC||law at redhat dot com

[Bug c++/79508] [6 Regression] Parse error in template argument list using nested template arguments

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79508

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Jason Merrill  ---
Fixed for 6.4.

[Bug lto/80407] --as-needed cannot be combined with -flto

2017-04-12 Thread dilyan.palauzov at aegee dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80407

Дилян Палаузов  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |MOVED

--- Comment #3 from Дилян Палаузов  ---
Moved to https://sourceware.org/bugzilla/show_bug.cgi?id=21382 .

[Bug c++/79519] [5/6 Regression] ICE deleting template friend function

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79519

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|5.5 |6.4

--- Comment #6 from Jason Merrill  ---
Fixed for 6.4.

[Bug target/80099] ICE in rs6000_expand_vector_extract, at config/rs6000/rs6000.c:7450

2017-04-12 Thread meissner at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80099

--- Comment #2 from Michael Meissner  ---
The problem is rs6000_expand_vector_extract did not check for SFmode being
allowed in the Altivec (upper) registers, but the insn implementing the
variable extract had it as a condition.

In looking at the variable extract code, it currently does not require SFmode
to go in the Altivec registers, but it does require DImode to go into the
Altivec registers (vec_extract of V2DFmode will require DFmode to go in Altivec
registers instead of DImode).

[Bug c/80413] sanitizer detects undefined behaviour in gcov-io.c using -ftest-coverage

2017-04-12 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80413

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-04-12
 CC||marxin at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |marxin at gcc dot 
gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Martin Liška  ---
I'll take a look.

[Bug tree-optimization/79390] [7 Regression] 10% performance drop in SciMark2 LU after r242550

2017-04-12 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79390

Jeffrey A. Law  changed:

   What|Removed |Added

 CC||law at redhat dot com

--- Comment #29 from Jeffrey A. Law  ---
Jakub's fix addresses the last remaining issue IIUC.  Should we close this out?

[Bug c++/79640] [5/6 Regression] ICE with generic lambda expression

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79640

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|5.5 |6.4

--- Comment #7 from Jason Merrill  ---
Fixed for 6.4, not backporting to 5.

[Bug lto/79062] -Walloca-larger-than and -Wformat-overflow warnings disabled by -flto

2017-04-12 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79062

--- Comment #4 from Martin Sebor  ---
All of warn_format, warn_format_overflow, and warn_format_trunc are, in fact,
zero in gimple-ssa-sprintf.c when -flto is set.

At least one problem is the dependency of -Wformat-{overflow,truncation} in
c-common/c.opt on -Wformat, which in turn depends on -Wall.  I.e.,
-Wformat-overflow is LangEnabledBy(C ObjC C++ ObjC++, Wformat=, warn_format >=
1, 0), and doesn't mention LTO.  -Wformat depends on -Wall, neither of which
mentions LTO.  Adding LTO helps somewhat, in that explicitly specifying
-Wformat-overflow (or -truncation) enables the warning, but specifying -Wformat
or -Wall doesn't have the same effect.  To set flags based on dependencies
among options the C front end calls the generated C_handle_option_auto()
function in $objdir/gcc/options.c which initializes its set of options.  There
is an LTO_handle_option_auto() in $objdir/gcc/options.c as well but nothing
seems to call it.  So it looks like some basic pieces aren't hooked up quite
right for LTO.

[Bug fortran/80408] Problems with SIGNAL, pthread and print together

2017-04-12 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80408

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2017-04-12
 Ever confirmed|0   |1

--- Comment #2 from Dominique d'Humieres  ---
> You may not call arbitrary functions in signal context but only
> async-signal safe ones.

Thus invalid?

[Bug rtl-optimization/78116] [7 regression] Performance drop after r241173 on avx512 target

2017-04-12 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78116

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P2
 CC||law at redhat dot com

[Bug target/74563] [6/7 regression] Classic MIPS16 (non-MIPS16e) function return broken

2017-04-12 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=74563

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P2
 CC||law at redhat dot com

[Bug target/80098] ICE in curr_insn_transform, at lra-constraints.c:3816 on ppc64le

2017-04-12 Thread meissner at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80098

Michael Meissner  changed:

   What|Removed |Added

  Attachment #41180|0   |1
is obsolete||

--- Comment #3 from Michael Meissner  ---
Created attachment 41192
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41192=edit
Updated patch

[Bug c++/79566] [6 Regression] elaborated-type-specifier incorrectly rejected in range-based for

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79566

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Jason Merrill  ---
Fixed for 6.4.

[Bug c++/80038] [6/7 Regression] Random segfault using local vectors in Cilk function

2017-04-12 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80038

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P2  |P4

--- Comment #30 from Jeffrey A. Law  ---
Given that Cilk is likely to be deprecated, there's no way this should be a P2
issue.

[Bug middle-end/57955] [5/6/7 Regression] Uniquization of constants reduces alignment of initializers

2017-04-12 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57955

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P2
 CC||law at redhat dot com

[Bug target/80099] ICE in rs6000_expand_vector_extract, at config/rs6000/rs6000.c:7450

2017-04-12 Thread meissner at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80099

Michael Meissner  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |meissner at gcc dot 
gnu.org

[Bug target/77728] [5/6/7 Regression] Miscompilation multiple vector iteration on ARM

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728

--- Comment #15 from Jason Merrill  ---
(In reply to rguent...@suse.de from comment #13)
> IMHO TYPE_DECL shouldn't even _have_ DECL_ALIGN ...

Agreed.

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread babokin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #7 from Dmitry Babokin  ---
80404 and 80405 seemed similar, but different to me, so I decided to report
them separately. Anyway, after the latest fixes I still see 2 compile crashes.
I'm reducing them and will report here.

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread babokin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #8 from Dmitry Babokin  ---
Three errors in one test case. GCC r246882.

> cat f.cpp
extern const long long int var_7;
extern unsigned long int var_59;
int foo() {
  int a = (0 - 40U <= (0 == 8)) << !var_59 << (0 < var_7) == 0;
  int b = ((0 ^ 0) < long(1066066618772207110 <= 0)) / 0 << 0;
  return a+b;
}

> g++ -w -fsanitize=undefined -O0 -c f.cpp
f.cpp: In function ‘int foo()’:
f.cpp:3:5: error: mismatching comparison operand types
 int foo() {
 ^~~
unsigned int
int
_4 = D.2761 < 0;
f.cpp:3:5: error: type mismatch in shift expression
int
unsigned int
int
_19 = D.2761 << _18;
f.cpp:3:5: error: type mismatch in binary expression
int

long int

int

D.2772 = 0 / 0;
f.cpp:3:5: internal compiler error: verify_gimple failed

[Bug tree-optimization/79390] [7 Regression] 10% performance drop in SciMark2 LU after r242550

2017-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79390

--- Comment #30 from Jakub Jelinek  ---
I didn't close it because I wanted to see updated benchmark numbers.  Either
I'll grab the benchmark, or if somebody else posts the latest numbers, we can
close it or keep open depending on that.

[Bug c++/68372] [concepts] invalid use of pack expansion expression in member function template declaration

2017-04-12 Thread wilhelm.me...@hs-kl.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68372

--- Comment #2 from wilhelm.me...@hs-kl.de ---
This ICE exists still in gcc-7.0.1-20170412.

[Bug libfortran/67540] string_intrinsics_inc.c sanitizer detects null pointer passed to memcpy

2017-04-12 Thread zeccav at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67540

--- Comment #9 from Vittorio Zecca  ---
This test case is wrong.
It dereferences thrice a NULL pointer str4.
Unfortunately -fcheck=pointer does not detect this one. 
Just added to the CC list the test case author.

[Bug tree-optimization/51513] Only partially optimizes away __builtin_unreachable switch default case

2017-04-12 Thread bergner at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51513

Peter Bergner  changed:

   What|Removed |Added

URL|https://gcc.gnu.org/ml/gcc- |https://gcc.gnu.org/ml/gcc-
   |patches/2016-04/msg01915.ht |patches/2017-04/msg00607.ht
   |ml  |ml
   Assignee|unassigned at gcc dot gnu.org  |bergner at gcc dot 
gnu.org

--- Comment #9 from Peter Bergner  ---
New patch submitted.

[Bug c++/78282] [6 Regression] Overload resolution failure, in parameter pack expansion, inside a template class

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78282

--- Comment #6 from Jason Merrill  ---
Author: jason
Date: Wed Apr 12 19:23:02 2017
New Revision: 246889

URL: https://gcc.gnu.org/viewcvs?rev=246889=gcc=rev
Log:
PR c++/78282 - auto template and pack expansion

* pt.c (find_parameter_packs_r): Don't walk into the type of
templates other than template template-parameters.

Added:
branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp1y/auto-fn36.C
Modified:
branches/gcc-6-branch/gcc/cp/ChangeLog
branches/gcc-6-branch/gcc/cp/pt.c

[Bug c++/80150] [6 Regression] Internal compiler error when in in try_one_overload, at cp/pt.c:18903

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80150

--- Comment #6 from Jason Merrill  ---
Author: jason
Date: Wed Apr 12 19:23:37 2017
New Revision: 246894

URL: https://gcc.gnu.org/viewcvs?rev=246894=gcc=rev
Log:
PR c++/80150 - ICE with overloaded variadic deduction.

* pt.c (try_one_overload): Remove asserts.

Added:
branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp0x/variadic-unify-3.C
Modified:
branches/gcc-6-branch/gcc/cp/ChangeLog
branches/gcc-6-branch/gcc/cp/pt.c

[Bug c++/77563] [5/6 Regression] explicit constructor breaks narrowing conversion overload resolution

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77563

--- Comment #8 from Jason Merrill  ---
Author: jason
Date: Wed Apr 12 19:23:30 2017
New Revision: 246893

URL: https://gcc.gnu.org/viewcvs?rev=246893=gcc=rev
Log:
PR c++/77563 - missing ambiguous conversion error.

* call.c (convert_like_real): Use LOOKUP_IMPLICIT.

Added:
branches/gcc-6-branch/gcc/testsuite/g++.dg/overload/ambig3.C
Modified:
branches/gcc-6-branch/gcc/cp/ChangeLog
branches/gcc-6-branch/gcc/cp/call.c

[Bug c++/79640] [5/6 Regression] ICE with generic lambda expression

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79640

--- Comment #6 from Jason Merrill  ---
Author: jason
Date: Wed Apr 12 19:23:15 2017
New Revision: 246891

URL: https://gcc.gnu.org/viewcvs?rev=246891=gcc=rev
Log:
PR c++/79640 - infinite recursion with generic lambda.

* pt.c (tsubst_copy) [VAR_DECL]: Register the dummy instantiation
before substituting its initializer.

Added:
branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp1y/lambda-generic-const3.C
Modified:
branches/gcc-6-branch/gcc/cp/ChangeLog
branches/gcc-6-branch/gcc/cp/pt.c

[Bug c++/78282] [6 Regression] Overload resolution failure, in parameter pack expansion, inside a template class

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78282

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Jason Merrill  ---
Fixed on 6 branch as well.

[Bug c++/79519] [5/6 Regression] ICE deleting template friend function

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79519

--- Comment #5 from Jason Merrill  ---
Author: jason
Date: Wed Apr 12 19:23:23 2017
New Revision: 246892

URL: https://gcc.gnu.org/viewcvs?rev=246892=gcc=rev
Log:
PR c++/79519 - ICE with deleted template friend.

* decl.c (grokdeclarator): Complain about misplaced function
definition using =, as well.

Added:
branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp0x/deleted13.C
Modified:
branches/gcc-6-branch/gcc/cp/ChangeLog
branches/gcc-6-branch/gcc/cp/decl.c

[Bug c++/79607] [5/6 Regression] ICE with brace-initialization of static const member

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79607

--- Comment #5 from Jason Merrill  ---
Author: jason
Date: Wed Apr 12 19:22:56 2017
New Revision: 246888

URL: https://gcc.gnu.org/viewcvs?rev=246888=gcc=rev
Log:
PR c++/79607 - ICE with T{} initializer

* decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.

Added:
branches/gcc-6-branch/gcc/testsuite/g++.dg/template/init11.C
Modified:
branches/gcc-6-branch/gcc/cp/ChangeLog
branches/gcc-6-branch/gcc/cp/decl.c

[Bug c++/80043] [6/7 Regression] ICE with pointer-to-member-function and -fpermissive

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80043

--- Comment #4 from Jason Merrill  ---
Author: jason
Date: Wed Apr 12 19:23:09 2017
New Revision: 246890

URL: https://gcc.gnu.org/viewcvs?rev=246890=gcc=rev
Log:
PR c++/80043 - ICE with -fpermissive

* typeck.c (convert_for_assignment): Handle instantiate_type
not giving an error.

Added:
branches/gcc-6-branch/gcc/testsuite/g++.dg/parse/ptrmem7.C
Modified:
branches/gcc-6-branch/gcc/cp/ChangeLog
branches/gcc-6-branch/gcc/cp/typeck.c

[Bug c++/80150] [6 Regression] Internal compiler error when in in try_one_overload, at cp/pt.c:18903

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80150

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Jason Merrill  ---
Fixed for 6.4 as well.

[Bug c++/77563] [5 Regression] explicit constructor breaks narrowing conversion overload resolution

2017-04-12 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77563

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|5.5 |6.4
Summary|[5/6 Regression] explicit   |[5 Regression] explicit
   |constructor breaks  |constructor breaks
   |narrowing conversion|narrowing conversion
   |overload resolution |overload resolution

--- Comment #9 from Jason Merrill  ---
Fixed for 6.4.  Since the GCC 5 bug is just a strange diagnostic, I'm not going
to fix it there.

[Bug sanitizer/80414] New: [UBSAN] segfault with -fsanitize=undefined

2017-04-12 Thread d.khalikov at partner dot samsung.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80414

Bug ID: 80414
   Summary: [UBSAN] segfault with -fsanitize=undefined
   Product: gcc
   Version: 7.0.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: d.khalikov at partner dot samsung.com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

Created attachment 41191
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41191=edit
patch

Hello everyone.

I got segfault on 32 bit host with -fsanitize=undefined

My test case:

# cat test.c 

int main()
{
  long long offset = 10;
  char array[10];
  char c = array[offset];
  return 0;
}

# gcc -o test test.c -fsanitize=undefined -static-libubsan
# ./test

That happens while checking for bounds-strict option on 32 bit host.

As i can see gcc push value of the index to the stack before call 
__ubsan_handle_out_of_bounds

 67 subl$44, %esp
 68 movl$10, -32(%ebp)
 69 movl$0, -28(%ebp)
 70 movl-32(%ebp), %ebx
 71 movl-28(%ebp), %esi
 72 movl%ebx, %eax
 73 cmpl$9, %eax
 74 jbe .L2
 75 subl$8, %esp
 76 pushl   %eax
 77 pushl   $.Lubsan_data0
 78 call__ubsan_handle_out_of_bounds

instead clang push address of that index

 15 movl$10, -32(%ebp)
 16 movl-28(%ebp), %eax
 17 movl-32(%ebp), %ecx
 18 movl%ecx, %edx
 19 cmpl$10, %edx
 20 movl%eax, -44(%ebp) # 4-byte Spill
 21 movl%ecx, -48(%ebp) # 4-byte Spill
 22 jb  .LBB0_2
 23 # BB#1:
 24 leal.L__unnamed_1, %eax
 25 leal-40(%ebp), %ecx
 26 movl-48(%ebp), %edx # 4-byte Reload
 27 movl%edx, -40(%ebp)
 28 movl-44(%ebp), %esi # 4-byte Reload
 29 movl%esi, -36(%ebp)
 30 movl%eax, (%esp)
 31 movl%ecx, 4(%esp)
 32 calll   __ubsan_handle_out_of_bounds

In this case fix should be in IR generation for
__ubsan_handle_out_of_bounds.

Looks like tree val should be generated from original tree 
index and not from tree index which 
were converted to bound type.

diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 17965ef..c56f376 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -672,7 +672,8 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi)

   /* Pick up the arguments of the UBSAN_BOUNDS call.  */
   tree type = TREE_TYPE (TREE_TYPE (gimple_call_arg (stmt, 0)));
-  tree index = gimple_call_arg (stmt, 1);
+  tree index, orig_index;
+  index = orig_index = gimple_call_arg (stmt, 1);
   tree orig_index_type = TREE_TYPE (index);
   tree bound = gimple_call_arg (stmt, 2);

@@ -708,9 +709,9 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi)
  ? BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS
  : BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS_ABORT;
   tree fn = builtin_decl_explicit (bcode);
-  tree val = force_gimple_operand_gsi (gsi, ubsan_encode_value (index),
-  true, NULL_TREE, true,
-  GSI_SAME_STMT);
+  tree val
+   = force_gimple_operand_gsi (gsi, ubsan_encode_value (orig_index), true,
+   NULL_TREE, true, GSI_SAME_STMT);
   g = gimple_build_call (fn, 2, data, val);
 }
   gimple_set_location (g, loc);

I attached patch.
Tests with make check RUNTESTFLAGS="ubsan.exp" passed for x86 32bit 
and 64 bit host.

<    1   2