https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78337
Bug ID: 78337
Summary: "internal compiler error: Segmentation fault", using
local variable in lambda return-type deduction
Product: gcc
Version: 6.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: aaron.mcdaid at gmail dot com
Target Milestone: ---
Created attachment 40032
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40032&action=edit
c++ code
The following code generates a "internal compiler error: Segmentation fault".
Code and gcc trace attached.
If I specify that `f` is `constexpr`, then there is not a segmentation fault.
This code began as an attempt to identify at compile time if a given expression
can be treated as a constant expression, but here I have simplified it. (The
full code worked in clang in the manner that I expected. See
http://stackoverflow.com/a/40413051/146041 for more on the context.)
My hunch is that 'f' is the problem here. It is being used in the computation
of the return type of the generic lambda. In this particular codebase, I would
expect a conventional refusal to compile with an error message about the fact
that a constant expression is necessary as the non-type int parameter to the
template Void.
// g++ (GCC) 6.2.0
struct X {
static constexpr int foo (int b) {
return b;
}
};
template<int>
using Void = void;
template<typename F,typename A>
auto
bar(F f, A a) -> decltype( ( f(a) , 0 ) )
{ return {}; }
int main() {
//constexpr
int f = 3;
(void)f;
auto l = [](auto of_type_X)->
Void<(decltype(of_type_X):: foo(f) ,0)>{return;};
bar( l , X{});
}