From 5453bbef09e7c3afb3aa0227e99d225d055f90cb Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 29 Mar 2011 22:16:22 -0400 Subject: [PATCH] re PR c++/48265 ([C++0x] ICE: SIGSEGV (recursion in value_dependent_expression_p) when variable is used uninitialised) PR c++/48265 * pt.c (value_dependent_expression_p) [VAR_DECL]: Make sure the variable is constant before looking at its initializer. From-SVN: r171714 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 4 ++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c4df48dd746..855844688b6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-03-29 Jason Merrill + PR c++/48265 + * pt.c (value_dependent_expression_p) [VAR_DECL]: Make sure + the variable is constant before looking at its initializer. + PR c++/48319 * pt.c (value_dependent_expression_p): Handle TEMPLATE_ID_EXPR. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index aa0901be3be..5960e4624b6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18085,10 +18085,10 @@ value_dependent_expression_p (tree expression) return value_dependent_expression_p (DECL_INITIAL (expression)); case VAR_DECL: - /* A constant with integral or enumeration type and is initialized + /* A constant with literal type and is initialized with an expression that is value-dependent. */ if (DECL_INITIAL (expression) - && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (expression)) + && decl_constant_var_p (expression) && value_dependent_expression_p (DECL_INITIAL (expression))) return true; return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 48199a2fb7b..ede28b20e37 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-03-29 Jason Merrill + + * g++.dg/cpp0x/regress/value-dep1.C: New. + 2011-03-29 Steve Ellcey * gcc.dg/torture/pr47917.c: Use -std=gnu99 on HP-UX. diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C b/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C new file mode 100644 index 00000000000..112389d4a8e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C @@ -0,0 +1,7 @@ +// PR c++/48265 +// { dg-options -std=c++0x } + +template < int > struct S +{ + S () { const int i = i; i; }; +}; -- 2.30.2