apitrace
apitrace copied to clipboard
Warnings on FreeBSD: comparison of constant 17 with expression of type 'const enum dwarf_tag' is always false
/wrkdirs/usr/ports/devel/apitrace/work/apitrace-7.1-455-g7c76b90/thirdparty/libbacktrace/dwarf.c:1335:24: warning: comparison of constant 17 with expression of type 'const enum dwarf_tag' is always false [-Wtautological-constant-out-of-range-compare]
if (abbrev->tag == DW_TAG_compile_unit
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/devel/apitrace/work/apitrace-7.1-455-g7c76b90/thirdparty/libbacktrace/dwarf.c:1341:24: warning: comparison of constant 17 with expression of type 'const enum dwarf_tag' is always false [-Wtautological-constant-out-of-range-compare]
if (abbrev->tag == DW_TAG_compile_unit
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/devel/apitrace/work/apitrace-7.1-455-g7c76b90/thirdparty/libbacktrace/dwarf.c:1351:23: warning: comparison of constant 17 with expression of type 'const enum dwarf_tag' is always false [-Wtautological-constant-out-of-range-compare]
if (abbrev->tag == DW_TAG_compile_unit
/wrkdirs/usr/ports/devel/apitrace/work/apitrace-7.1-455-g7c76b90/thirdparty/libbacktrace/dwarf.c:2276:34: warning: comparison of constant 46 with expression of type 'const enum dwarf_tag' is always false [-Wtautological-constant-out-of-range-compare]
is_function = (abbrev->tag == DW_TAG_subprogram
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
That's worrying. This certainly looks like it should not be automatically false.
libbacktrace is a thirdparty lib. Perhaps it was fixed upstream.
Please confirm what's FreeBSD compiler and version.
Please confirm what's FreeBSD compiler and version.
clang-40 on FreeBSD 11.1
The warning is wrong and is corrected for upcoming releases of Clang: https://bugs.llvm.org//show_bug.cgi?id=35009
For Apitrace, I suggest changing definitions of dummy enums to make the range wide enough to cover all actual values (technically, with the current definition, dummy enums could correspond to char-sized integer types, which would be wrong). Like this, untested:
diff --git a/thirdparty/libbacktrace/auxincl/dwarf2.h b/thirdparty/libbacktrace/auxincl/dwarf2.h
index 362ef451..901de77b 100644
--- a/thirdparty/libbacktrace/auxincl/dwarf2.h
+++ b/thirdparty/libbacktrace/auxincl/dwarf2.h
@@ -40,9 +40,9 @@ POSSIBILITY OF SUCH DAMAGE. */
#endif
/* Provide stub enum tags. */
-enum dwarf_attribute {_dummy_dwarf_attribute};
-enum dwarf_form {_dummy_dwarf_form};
-enum dwarf_tag {_dummy_dwarf_tag};
+enum dwarf_attribute {_dummy_dwarf_attribute = ~0u};
+enum dwarf_form {_dummy_dwarf_form = ~0u};
+enum dwarf_tag {_dummy_dwarf_tag = ~0u};
/* Define potentially missing enum values. */
#define DW_FORM_GNU_addr_index 0x1f01
To clarify, the diff proposed above would have nothing to do with libbacktrace upstream: auxincl/dwarf2.h
is an Apitrace addition replacing an internal GCC header file.