Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp
@ 2016-09-11 14:22 Jan Kratochvil
  2016-09-15 12:22 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2016-09-11 14:22 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]

Hi,

gcc-6.2.1-1.fc26.x86_64

g++ -std=c++03:
no warnings

g++:
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:0:
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:34: 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 = 3.14159;
                                  ^~~~~~~

clang++:
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: warning: in-class initializer for static data member of type 'const float' is a GNU extension [-Wgnu-static-float-init]
  static const float somewhere = 3.14159;
                     ^           ~~~~~~~
1 warning generated.

clang++ -std=c++11:
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: error: in-class initializer for static data member of type 'const float' requires 'constexpr' specifier [-Wstatic-float-init]
  static const float somewhere = 3.14159;
                     ^           ~~~~~~~
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:3: note: add 'constexpr'
  static const float somewhere = 3.14159;
  ^
  constexpr
1 error generated.

OK for check-in?

After the fix out of the 4 combinations above only this one remains non-empty:

clang++:
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: warning: in-class initializer for static data member of type 'const float' is a GNU extension [-Wgnu-static-float-init]
  static const float somewhere = 3.14159;
                     ^           ~~~~~~~
1 warning generated.


Jan

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 609 bytes --]

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

	* gdb.cp/m-static.h (gnu_obj_4::somewhere): Use constexpr for C++11.

diff --git a/gdb/testsuite/gdb.cp/m-static.h b/gdb/testsuite/gdb.cp/m-static.h
index bcedfff..2992463 100644
--- a/gdb/testsuite/gdb.cp/m-static.h
+++ b/gdb/testsuite/gdb.cp/m-static.h
@@ -6,6 +6,9 @@ class gnu_obj_4
   static const int elsewhere;
   static const int nowhere;
   static const int everywhere = 317;
+#if __cplusplus >= 201103L
+  constexpr
+#endif
   static const float somewhere = 3.14159;
 
   // try to ensure test4 is actually allocated

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp
  2016-09-11 14:22 [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp Jan Kratochvil
@ 2016-09-15 12:22 ` Pedro Alves
  2016-09-15 12:34   ` Jan Kratochvil
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2016-09-15 12:22 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches

On 09/11/2016 03:22 PM, Jan Kratochvil wrote:
> 
> After the fix out of the 4 combinations above only this one remains non-empty:
> 
> clang++:
> In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
> /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: warning: in-class initializer for static data member of type 'const float' is a GNU extension [-Wgnu-static-float-init]
>   static const float somewhere = 3.14159;
>                      ^           ~~~~~~~
> 1 warning generated.
> 

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?

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp
  2016-09-15 12:22 ` Pedro Alves
@ 2016-09-15 12:34   ` Jan Kratochvil
  2016-09-15 13:11     ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2016-09-15 12:34 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

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

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 1309 bytes --]

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;
 };
-

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp
  2016-09-15 12:34   ` Jan Kratochvil
@ 2016-09-15 13:11     ` Pedro Alves
  2016-09-15 21:47       ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2016-09-15 13:11 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On 09/15/2016 01:34 PM, Jan Kratochvil wrote:
> 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.
> 

Hmm, OK, now that I read the test, I think you were right in trying to 
keep it safe, actually.  The .exp file has:

# static const initialized in the class definition, PR gdb/11702.
if { $non_dwarf } { setup_xfail *-*-* }
gdb_test "print test4.everywhere" "\\$\[0-9\].* = 317" "static const int initialized in class definition"
if { $non_dwarf } { setup_xfail *-*-* }
gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const float initialized in class definition"
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Added by this:

 https://sourceware.org/bugzilla/show_bug.cgi?id=11702
 https://sourceware.org/ml/gdb-patches/2010-06/msg00677.html
 https://sourceware.org/ml/gdb-patches/2010-06/txt00011.txt

So the new patch would make that highlighted tested above not
test what its test message says it is testing.

So I now think your original patch is better.  Please push
that one instead.

(Even better would be to rewrite the test using the
dwarf assembler, but that'd of course be much more work.)

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [commit] [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp
  2016-09-15 13:11     ` Pedro Alves
@ 2016-09-15 21:47       ` Jan Kratochvil
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kratochvil @ 2016-09-15 21:47 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Thu, 15 Sep 2016 15:10:50 +0200, Pedro Alves wrote:
> So I now think your original patch is better.  Please push
> that one instead.

d2dfe7003423d41394d2475680e55af796566b8e


Thanks,
Jan


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-15 21:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-11 14:22 [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp Jan Kratochvil
2016-09-15 12:22 ` Pedro Alves
2016-09-15 12:34   ` Jan Kratochvil
2016-09-15 13:11     ` Pedro Alves
2016-09-15 21:47       ` [commit] " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox