re PR c++/77555 (unused inline function in-function static variable accessed from...
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 23 Oct 2017 11:39:20 +0000 (11:39 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 23 Oct 2017 11:39:20 +0000 (11:39 +0000)
2017-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/77555
* g++.dg/torture/pr77555.C: New.

From-SVN: r254006

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr77555.C [new file with mode: 0644]

index 9ca1131..2af517e 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-23  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/77555
+       * g++.dg/torture/pr77555.C: New.
+
 2017-10-23  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/82129
diff --git a/gcc/testsuite/g++.dg/torture/pr77555.C b/gcc/testsuite/g++.dg/torture/pr77555.C
new file mode 100644 (file)
index 0000000..540d1a0
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do link }
+// { dg-options "-std=c++11" }
+
+extern "C" int printf(const char*, ...);
+struct A {
+  A(int, char *p2) { printf(p2); }
+};
+template <int, typename> struct B { static A static_var; };
+template <int LINE, typename GETTER>
+A B<LINE, GETTER>::static_var{0, GETTER::get()};
+struct C {
+  void unused() {
+    static char function_static;
+    struct D {
+      static char *get() { return &function_static; }
+    };
+    auto addr = B<0, D>::static_var;
+  }
+};
+int main() {}