Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings on FreeBSD: comparison of constant 17 with expression of type 'const enum dwarf_tag' is always false #533

Open
yurivict opened this issue Nov 15, 2017 · 4 comments
Assignees
Labels

Comments

@yurivict
Copy link

yurivict commented Nov 15, 2017

/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
                     ~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~
@jrfonseca
Copy link
Member

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.

@yurivict
Copy link
Author

Please confirm what's FreeBSD compiler and version.

clang-40 on FreeBSD 11.1

@amonakov
Copy link
Member

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

@amonakov
Copy link
Member

amonakov commented Dec 5, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants