From: Tom Tromey Date: Thu, 20 Mar 2025 13:52:24 +0000 (-0600) Subject: Use attribute::signed_constant in attribute::as_boolean X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cdcd13791f7de81f80ab12f5426fe002430f38b6;p=thirdparty%2Fbinutils-gdb.git Use attribute::signed_constant in attribute::as_boolean This changes attribute::as_boolean to use attribute::signed_constant. This is maybe overkill but lets any reasonable constant form through. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32680 --- diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 7d6372d1574..8ff03531613 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -326,5 +326,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; }