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

Build with more aggressive compiler warnings #223

Open
springmeyer opened this issue Apr 26, 2016 · 13 comments
Open

Build with more aggressive compiler warnings #223

springmeyer opened this issue Apr 26, 2016 · 13 comments

Comments

@springmeyer
Copy link
Contributor

springmeyer commented Apr 26, 2016

My sense is we should start with enabling and fixing warnings in roughly this order:

  • -Wabsolute-value
  • -Wfloat-conversion
  • -Wshorten-64-to-32
  • -Wconversion
  • -Wshadow
  • -Wsign-compare
  • -Wsign-conversion
@e-n-f
Copy link
Contributor

e-n-f commented May 3, 2016

-Wshadow should be fixed in f1b3f6d

@springmeyer
Copy link
Contributor Author

@ericfischer - refreshed, recommended list is now available at mapbox/cpp#37

@e-n-f
Copy link
Contributor

e-n-f commented Nov 7, 2017

Thanks. Working on this in #489

@springmeyer
Copy link
Contributor Author

Thanks @ericfischer

@springmeyer
Copy link
Contributor Author

@ericfischer great to see #489 land. Any progress on attempting -Wconversion or is it looking too narly?

@e-n-f
Copy link
Contributor

e-n-f commented Nov 28, 2017

That one is going to be terrible. There are hundreds of implicit type conversions.

@springmeyer
Copy link
Contributor Author

@ericfischer okay, then I recommend starting with a subset like:

-Wbitfield-enum-conversion, -Wbool-conversion, -Wconstant-conversion, -Wenum-conversion, - -Wliteral-conversion, -Wnon-literal-null-conversion, -Wnull-conversion, -Wshorten-64-to-32, -Wstring-conversion.

I presume that will surface much fewer warnings, primarily from -Wshorten-64-to-32.

The whole -Wconversion group is listed at https://clang.llvm.org/docs/DiagnosticsReference.html#wconversion.

After those are resolved I recommend one-by-one incrementally adding -Wsign-conversion, then -Wint-conversion, and finally -Wfloat-conversion (which is often too much in my experience, but nevertheless useful to peek at even if you don't fix them).

@springmeyer
Copy link
Contributor Author

@ericfischer do you have thoughts on my proposed plan?

@e-n-f
Copy link
Contributor

e-n-f commented Dec 8, 2017

I can certainly go through and add 571 type casts. I'm just not sure what the balance will turn out to be between:

  • fixing genuine bugs
  • adding needless clutter
  • accidentally masking genuine bugs by adding casts that make errors look intentional

which is always my anxiety around casts. I hope there will be more of the former than of the latter two though.

@e-n-f
Copy link
Contributor

e-n-f commented Dec 8, 2017

The fundamental tension is that the language really wants array bounds and indices to be unsigned, for efficiency, but really wants ordinary arithmetic to be signed, for intuitive results.

@e-n-f
Copy link
Contributor

e-n-f commented Dec 12, 2017

Trying to get more rigorous about numeric types in #506.

Situations I've encountered so far that are stuck as int but perhaps should not be:

  • Tile coordinate detail (log2(extent))
  • Global scaling factor for tile coordinates
  • Feature flags (because that's what getopt_long wants)
  • Comparator return values (because that's what qsort wants)
  • Zoom levels
  • File descriptors (because that's what open et al want)
  • Attribute types (for coercion)
  • Exit status
  • Char+EOF return values from getc
  • Char+EOF return from getopt_long, and optind option index

@springmeyer
Copy link
Contributor Author

Excellent progress @ericfischer - I notice that branch fixes a number of the -Wshorten-64-to-32 warnings. Some that remain are coming from the zlib wrapper code, which reminds me that these warnings are solved in https://github.com/mapbox/gzip-hpp, which is fundamentally a port of the same code in tippecanoe into a standalone module with the warnings (and potential overflows) resolved.

@e-n-f
Copy link
Contributor

e-n-f commented Dec 14, 2017

What remains now is a handful of int-to-char conversions and hundreds of sign conversions.

Lumyk pushed a commit to cropio/tippecanoe that referenced this issue Jun 18, 2024
upgrade catch from v1.5.7 to v2.13.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants