[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-05 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

Jason Merrill  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Jason Merrill  ---
Original testcase also fixed, now.

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-05 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

--- Comment #7 from Jason Merrill  ---
Author: jason
Date: Thu Apr  5 14:20:53 2018
New Revision: 259127

URL: https://gcc.gnu.org/viewcvs?rev=259127=gcc=rev
Log:
PR c++/85200 - ICE with constexpr if in generic lambda.

* pt.c (extract_locals_r): Don't record the local specs of variables
declared within the pattern.

Added:
trunk/gcc/testsuite/g++.dg/cpp1z/constexpr-if19.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-05 Thread benni.buch at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

Benjamin Buch  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #5 from Benjamin Buch  ---
First test case still fails with a wrong error message and an ICE:

struct A{
constexpr operator int(){ return 0; }
};

template < typename >
void f(){
[](auto known){
if constexpr(constexpr int k = known);
}(A{});
}

int main(){
f();
}


$ g++ -std=c++17 main.cpp   
main.cpp: In lambda function:
main.cpp:7:18: error: Local declaration from a different function
 [](auto known){
  ^
k   
main.cpp:8:36: note: in statement
 if constexpr(constexpr int k = known);
^
k = 0;  
during GIMPLE pass: cfg 
main.cpp:7:18: internal compiler error: verify_gimple failed
 [](auto known){
  ^
0xed1883 verify_gimple_in_cfg(function*, bool)  
../../gcc/gcc/tree-cfg.c:5585   
0xdb891f execute_function_todo  
../../gcc/gcc/passes.c:1994 
0xdb986e execute_todo   
../../gcc/gcc/passes.c:2048
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

$ g++ --version
g++ (GCC) 8.0.1 20180405 (experimental)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


GCC 7 and clang 8 are accepting the code.

I'm not sure what the error message means, but I'm quite sure it isn't correct
here.

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-04 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

Jason Merrill  changed:

   What|Removed |Added

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

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

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-04 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

--- Comment #3 from Jason Merrill  ---
Author: jason
Date: Wed Apr  4 19:10:38 2018
New Revision: 259099

URL: https://gcc.gnu.org/viewcvs?rev=259099=gcc=rev
Log:
PR c++/85200 - ICE with constexpr if in generic lambda.

* tree.c (cp_walk_subtrees): Walk into DECL_EXPR in templates.

Added:
trunk/gcc/testsuite/g++.dg/cpp1z/constexpr-if18.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/tree.c

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-04 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

Jason Merrill  changed:

   What|Removed |Added

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

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

Jakub Jelinek  changed:

   What|Removed |Added

   Priority|P3  |P1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-04-04
 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Jakub Jelinek  ---
Started with r259043.

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-04 Thread benni.buch at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

--- Comment #1 from Benjamin Buch  ---
Another version of the ICE is:

struct B{
constexpr operator bool(){ return 1; }
};

template < typename >
void f(){
[](auto v, auto b){
if constexpr(b){
auto x = [](auto){ return 0; }(v);
}
}(0, B{});
}

int main(){
f();
}


$ g++ -std=c++17 main.cpp
main.cpp: In instantiation of 'f() [with  =
int]:: [with auto:1 = int; auto:2 = B]':
main.cpp:11:6:   required from 'void f() [with  = int]'
main.cpp:15:12:   required from here
main.cpp:9:44: internal compiler error: in tsubst_copy, at cp/pt.c:15001
 auto x = [](auto){ return 0; }(v);
^
0x611c81 tsubst_copy
../../gcc/gcc/cp/pt.c:15001
0x930440 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/gcc/cp/pt.c:18504
0x9328ae tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/gcc/cp/pt.c:18623
0x930d9d tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/gcc/cp/pt.c:17925
0x93f6bf tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/gcc/cp/pt.c:17345
0x93f6bf tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:17077
0x9423c2 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:14946
0x9423c2 tsubst_init
../../gcc/gcc/cp/pt.c:14950
0x940ec8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16391
0x93ee24 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16264
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16561
0x94097e tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16531
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16561
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16561
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16561
0x93b9b8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../gcc/gcc/cp/pt.c:16249
0x93b9b8 instantiate_decl(tree_node*, bool, bool)
../../gcc/gcc/cp/pt.c:23659
0x882f9b maybe_instantiate_decl
../../gcc/gcc/cp/decl2.c:5190
0x884fd7 mark_used(tree_node*, int)
../../gcc/gcc/cp/decl2.c:5291
0x7eee9a build_over_call
../../gcc/gcc/cp/call.c:8246
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

$ g++ --version
g++ (GCC) 8.0.1 20180404 (experimental)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Again known to work with GCC 7:
$ g++-7 --version
g++-7 (GCC) 7.3.1 20180226
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/85200] [8 Regression] ICE in constexpr-if in lambda in template

2018-04-04 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85200

Richard Biener  changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
   Target Milestone|--- |8.0