Fix crash in cp_print_value_fields
authorTom Tromey <tromey@adacore.com>
Sat, 3 Aug 2019 07:42:28 +0000 (09:42 +0200)
committerTom de Vries <tdevries@suse.de>
Sat, 3 Aug 2019 07:42:28 +0000 (09:42 +0200)
commit98c90f80283bbdf7df140041e3b784bfcb3b1d39
tree24f5df1afaf0b17a6c419e41b79451813ec36343
parent0bcd30db25ee1605a1a625cf86da3a3875a95b91
Fix crash in cp_print_value_fields

[ Backport of master commit 4330d61dfb. ]

PR c++/20020 concerns a crash in cp_print_value_fields.  The immediate
cause is that cp_print_value_fields does not handle the case where
value_static_field fails.  This is fixed in this patch by calling
cp_print_static_field from the "try" block.

Digging a bit deeper, the error occurs because GCC does not emit a
DW_AT_const_value for a static constexpr member appearing in a
template class.  I've filed a GCC bug for this.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

PR c++/20020:
* cp-valprint.c (cp_print_value_fields): Call
cp_print_static_field inside "try".

gdb/testsuite/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

PR c++/20020:
* gdb.cp/constexpr-field.exp: New file.
* gdb.cp/constexpr-field.cc: New file.
gdb/ChangeLog
gdb/cp-valprint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/constexpr-field.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/constexpr-field.exp [new file with mode: 0644]