Hi Jeff,
The attached patch adds the test derived from the BZ. There is one small problem - I could not find a way to stop the additional source file from being compiled as a test on its own.
I think for C++ code it's usually worked around by naming the additional-source file with ".cc" rather than .C. Can you give that a quick whirl and see if that avoids having the additional file used as a a test on its own?
Thanks - that worked. :-) Revised test attached. OK to apply ? Cheers Nick
--- /dev/null 2016-01-07 09:30:14.144966933 +0000 +++ gcc/testsuite/g++.dg/pr66655.C 2016-01-07 12:13:15.757187619 +0000 @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-additional-sources "pr66655_1.cc" } */ + +#include "pr66655.h" + +extern "C" void abort (void); + +#define COOKIE 0xabcd0123 + +int +g (void) +{ + return COOKIE; +} + +extern int f (void); + +int +main (void) +{ + S::set(0); + if (f () != COOKIE) + abort (); + return 0; +} --- /dev/null 2016-01-07 09:30:14.144966933 +0000 +++ gcc/testsuite/g++.dg/pr66655_1.cc 2016-01-07 12:04:30.586623022 +0000 @@ -0,0 +1,14 @@ +#include "pr66655.h" + +extern int g (void); + +int S::i; + +int +f (void) +{ + int ret = g (); + + S::set (ret); + return ret; +} --- /dev/null 2016-01-07 09:30:14.144966933 +0000 +++ gcc/testsuite/g++.dg/pr66655.h 2016-01-05 10:41:45.629561622 +0000 @@ -0,0 +1,5 @@ +struct S +{ + static int i; + static void set (int ii) { i = -ii; } +};