/usr/src/gcc-4.8/debian/patches/pr62255.diff is in gcc-4.8-source 4.8.5-4ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # DP: Backport PR c++/62255 (rejects-valid)
gcc/cp/
2015-02-25 Jason Merrill <jason@redhat.com>
PR c++/62255
* pt.c (instantiate_decl): Handle recursive instantiation of
static data member.
Index: b/src/gcc/cp/pt.c
===================================================================
--- a/src/gcc/cp/pt.c
+++ b/src/gcc/cp/pt.c
@@ -18856,13 +18856,18 @@ instantiate_decl (tree d, int defer_ok,
args,
tf_warning_or_error, NULL_TREE,
/*integral_constant_expression_p=*/false);
- /* Make sure the initializer is still constant, in case of
- circular dependency (template/instantiate6.C). */
- const_init
- = DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (code_pattern);
- cp_finish_decl (d, init, /*init_const_expr_p=*/const_init,
- /*asmspec_tree=*/NULL_TREE,
- LOOKUP_ONLYCONVERTING);
+ /* If instantiating the initializer involved instantiating this
+ again, don't call cp_finish_decl twice. */
+ if (!DECL_INITIAL (d))
+ {
+ /* Make sure the initializer is still constant, in case of
+ circular dependency (template/instantiate6.C). */
+ const_init
+ = DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (code_pattern);
+ cp_finish_decl (d, init, /*init_const_expr_p=*/const_init,
+ /*asmspec_tree=*/NULL_TREE,
+ LOOKUP_ONLYCONVERTING);
+ }
pop_nested_class ();
pop_nested_namespace (ns);
}
Index: b/src/gcc/testsuite/g++.dg/template/recurse4.C
===================================================================
--- /dev/null
+++ b/src/gcc/testsuite/g++.dg/template/recurse4.C
@@ -0,0 +1,18 @@
+// PR c++/62255
+
+// It's not clear whether this is well-formed; instantiating the
+// initializer of 'value' causes the instantiation of Derived, which in
+// turn requires the value of 'value', but the recursion ends there, so it
+// seems reasonable to allow it.
+
+template <typename T> struct Test {
+ template<typename X> static int check(typename X::Type*);
+ template<typename> static char check(...);
+ static const bool value = (sizeof(check<T>(0)) == sizeof(int));
+};
+template <int> struct Sink { };
+template <typename T> struct Derived : Sink<Test<Derived<T> >::value> {
+ typedef int Type;
+};
+
+Sink<Test<Derived<int> >::value> s;
|