From 2de9164b45111b54bea99afd97ca4f0de382a5e3 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 23 Oct 2017 11:39:20 +0000 Subject: [PATCH] re PR c++/77555 (unused inline function in-function static variable accessed from outside leads to linker error) 2017-10-23 Paolo Carlini PR c++/77555 * g++.dg/torture/pr77555.C: New. From-SVN: r254006 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr77555.C | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr77555.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9ca1131a..2af517e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-23 Paolo Carlini + + PR c++/77555 + * g++.dg/torture/pr77555.C: New. + 2017-10-23 Richard Biener 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 index 0000000..540d1a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr77555.C @@ -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 struct B { static A static_var; }; +template +A B::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() {} -- 2.7.4