[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2016-03-02 Thread clyon at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

--- Comment #11 from Christophe Lyon  ---
gcc-5-branch fixed by r233903.

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2016-03-02 Thread clyon at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

Christophe Lyon  changed:

   What|Removed |Added

 CC||clyon at gcc dot gnu.org

--- Comment #10 from Christophe Lyon  ---
The backport on gcc-5-branch fails on ARM targets, because GCC complains with:
array subscript out of bound

The same test does pass on AArch64.

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2016-03-01 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

--- Comment #9 from Jason Merrill  ---
Author: jason
Date: Wed Mar  2 02:45:45 2016
New Revision: 233882

URL: https://gcc.gnu.org/viewcvs?rev=233882&root=gcc&view=rev
Log:
PR c++/68087

2016-03-01  Markus Trippelsdorf  
Paolo Carlini  
/cp
* constexpr.c (cxx_eval_array_reference): Use tree_fits_shwi_p before
tree_to_shwi to avoid ICEs.

Modified:
branches/gcc-5-branch/gcc/cp/ChangeLog
branches/gcc-5-branch/gcc/cp/constexpr.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog
branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-array13.C

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-25 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

--- Comment #8 from Paolo Carlini  ---
I see, thanks. I'm going to trivially tweak the dg-error.

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-25 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek  ---
The testcase fails on i686-linux:
/home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-array13.C:6:26: error:
array subscript out of bound
compiler exited with status 1
output is:
/home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-array13.C:6:26: error:
array subscript out of bound

FAIL: g++.dg/cpp0x/constexpr-array13.C  -std=c++11  (test for errors, line 6)
FAIL: g++.dg/cpp0x/constexpr-array13.C  -std=c++11 (test for excess errors)
Excess errors:
/home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-array13.C:6:26: error:
array subscript out of bound

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-25 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

Markus Trippelsdorf  changed:

   What|Removed |Added

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

--- Comment #6 from Markus Trippelsdorf  ---
Fixed. Thanks for handling this, Paolo.

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-25 Thread paolo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

--- Comment #5 from paolo at gcc dot gnu.org  ---
Author: paolo
Date: Wed Nov 25 16:42:18 2015
New Revision: 230887

URL: https://gcc.gnu.org/viewcvs?rev=230887&root=gcc&view=rev
Log:
/cp
2015-11-25  Markus Trippelsdorf  
Paolo Carlini  

PR c++/68087
* constexpr.c (cxx_eval_array_reference): Use tree_fits_shwi_p before
tree_to_shwi to avoid ICEs.

/testsuite
2015-11-25  Markus Trippelsdorf  
Paolo Carlini  

PR c++/68087
* g++.dg/cpp0x/constexpr-array13.C: New.

Added:
branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-array13.C
Modified:
branches/gcc-5-branch/gcc/cp/ChangeLog
branches/gcc-5-branch/gcc/cp/constexpr.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-25 Thread paolo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

--- Comment #4 from paolo at gcc dot gnu.org  ---
Author: paolo
Date: Wed Nov 25 16:40:16 2015
New Revision: 230886

URL: https://gcc.gnu.org/viewcvs?rev=230886&root=gcc&view=rev
Log:
/cp
2015-11-25  Markus Trippelsdorf  
Paolo Carlini  

PR c++/68087
* constexpr.c (cxx_eval_array_reference): Use tree_fits_shwi_p before
tree_to_shwi to avoid ICEs.

/testsuite
2015-11-25  Markus Trippelsdorf  
Paolo Carlini  

PR c++/68087
* g++.dg/cpp0x/constexpr-array13.C: New.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-array13.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/constexpr.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-25 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

Paolo Carlini  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |paolo.carlini at oracle 
dot com

--- Comment #3 from Paolo Carlini  ---
Testing variants of Markus' suggestion.

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

Richard Biener  changed:

   What|Removed |Added

   Keywords|ice-on-invalid-code |ice-on-valid-code
   Priority|P3  |P2
Version|unknown |6.0

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-11-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |5.3

[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-10-25 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

--- Comment #2 from Markus Trippelsdorf  ---
Perhaps:

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index ebca411..0828a90 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1782,8 +1782,7 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree
t,
   gcc_unreachable ();
 }

-  i = tree_to_shwi (index);
-  if (i < 0)
+  if (!tree_fits_shwi_p (index) || tree_to_shwi (index) < 0)
 {
   if (!ctx->quiet)
error ("negative array subscript");
@@ -1792,6 +1791,7 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree
t,
 }

   bool found;
+  i = tree_to_shwi (index);
   if (TREE_CODE (ary) == CONSTRUCTOR)
 {
   HOST_WIDE_INT ix = find_array_ctor_elt (ary, index);


[Bug c++/68087] [5/6 Regression] ICE with constexpr in array with negative index

2015-10-25 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68087

Markus Trippelsdorf  changed:

   What|Removed |Added

   Keywords||ice-on-invalid-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-10-25
 CC||trippels at gcc dot gnu.org
 Blocks||55004
Summary|ICE with constexpr in array |[5/6 Regression] ICE with
   |with negative index |constexpr in array with
   ||negative index
 Ever confirmed|0   |1

--- Comment #1 from Markus Trippelsdorf  ---
Confirmed.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004
[Bug 55004] [meta-bug] constexpr issues