This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp


On Thu, 15 Sep 2016 14:22:54 +0200, Pedro Alves wrote:
> Did you try moving the initialization to the .cc file?  Like:
> 
> const float gnu_obj_4::somewhere = 3.14159;
> 
> Did you find a reason to not do that?

I have found that it may invalidate the testcase some way so I stayed on the
safe side.  I have read now briefly the .exp file and it does have some XFAIL
around "extra CU-level DW_TAG_variable as DW_AT_declaration".

But those compiler bugs should be forgotten now so I am fine even with this
new patch below.


Jan
gdb/testsuite/ChangeLog
2016-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.cp/m-static.cc (gnu_obj_4::somewhere): New.
	* gdb.cp/m-static.h (class gnu_obj_4): Remove somewhere initializer.

diff --git a/gdb/testsuite/gdb.cp/m-static.cc b/gdb/testsuite/gdb.cp/m-static.cc
index cb871e8..e5e2d62 100644
--- a/gdb/testsuite/gdb.cp/m-static.cc
+++ b/gdb/testsuite/gdb.cp/m-static.cc
@@ -77,6 +77,7 @@ gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
 // 2002-08-16
 // Test four.
 #include "m-static.h"
+const float gnu_obj_4::somewhere = 3.14159;
 
 // instantiate templates explicitly so their static members will exist
 template class gnu_obj_2<int>;
diff --git a/gdb/testsuite/gdb.cp/m-static.h b/gdb/testsuite/gdb.cp/m-static.h
index bcedfff..083e1e2 100644
--- a/gdb/testsuite/gdb.cp/m-static.h
+++ b/gdb/testsuite/gdb.cp/m-static.h
@@ -6,9 +6,10 @@ class gnu_obj_4
   static const int elsewhere;
   static const int nowhere;
   static const int everywhere = 317;
-  static const float somewhere = 3.14159;
+  // see m-static.cc - otherwise:
+  // error: 'constexpr' needed for in-class initialization of static data member 'const float gnu_obj_4::somewhere' of non-integral type [-fpermissive]
+  static const float somewhere;
 
   // try to ensure test4 is actually allocated
   int dummy;
 };
-

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]