diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c
index 25cf2b62cfd1c8f4981be2787fe4ade8c8c66b81..d3b3eed81bd500bf06dc8c83cab7ae1fa8c17974 100644
--- a/gdb/dwarf2/attribute.c
+++ b/gdb/dwarf2/attribute.c
@@ -323,5 +323,8 @@ attribute::as_boolean () const
     return true;
   else if (form == DW_FORM_flag)
     return u.unsnd != 0;
-  return constant_value (0) != 0;
+  /* Using signed_constant here will work even for the weird case
+     where a negative value is provided.  Probably doesn't matter but
+     also seems harmless.  */
+  return signed_constant ().value_or (0) != 0;
 }
