-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Lots of warnings when compiling with Visual Studio 2019 #1866
Comments
We have Visual Studio 2017 and Visual Studio 2019 in the GiHub Actions and see the same mess. We are using the CMake targets though. I had a look through the warnings (some time ago) and found most of it noise. "Fixing" seemed to be lots of workarounds to make the MSVC happy. I wouldn't bother with the conversion warnings, maybe pick a few and check if there is really a problem we missed. Maybe look into it if that's the last thing coming up in warnings :) Fixing the Posix stuff can only help portability, I guess it's just some I didn't spot any format string type mismatches, those should be addressed. Shadowing should be fixed, bad practice. When the project started there was no tight scoping, just 4 instances left sounds good ;) As const is not a guarantee the problems need to be fixed, then at least the compiler can report some level of sanity there. |
Regarding the double to float warnings for example: And the 4 C6246 warnings should definitive be fixed. And C6340 seems looks like valid varnings also. The following warning: So fixes for those warnings will be accepted. But leave mongoose alone, those should be fixed upstream. Go for all the easy changes first then we can look into the other warnings that may hide real issues. |
I'm playing with GCC warnings and will perhaps fix some things. Hold off for a day or two ;) |
I've added some warnings and fixed those, 6c8af75. E.g. The intentional switch fallthrough is a handful, but it's only a single one we have and we'd really want a warning for that easy to make mistake.
The promotion and conversion warnings are not fun. So much noise. |
Well, I did have to change the prebuilt path to get a building environment, and the instructions aren't that clear but I'm very used to Visual Studio C++.
Yes, I agree that a hard cast is not nice, but the warning is not really about a missing cast but rather about a missing decision: should it be I'm going to create various branches for the various "families" of warnings and issue the associated pull requests, keeping in mind suggestions made in this issue. |
Seems like a lot of these have been resolved. But there are open linked PRs. @obones My impression is that fixing UB is good, as long as we don't get icky, and that separate PRs for separate problems is probably best. You may want to freshen the unmerged PRs and/or open some new ones. I'm not sure this issue is useful, as if there is a PR, it should be examined, and if not, then I don't think anybody is going to go work on VS stuff because of the issue. But "there are warnings in the code that appear valid" is fair, so I don't object to it being open. |
I have rebased and adjusted the three branches linked to the three PRs mentioning this issue. |
We have PRs so am going to close this. Feel free to file PRs to clean up things or to poke about the PRs. |
I know my situation is a bit unusual, but I'm using Visual Studio 2019 to build this project. I'm using the solution file placed in the
vs15
folder that was updated by the IDE.As a base principle, I want zero messages from the compiler but when building the master branch, I get more than 300 warnings which I have placed in the following CSV file: warnings.csv
Here is a summary of the situation:
250 C4244/C4267/C4305 warnings: "conversion from XX to YY, possible loss of data"
Most are from
double
tofloat
and come from floating point literalsThen there are conversions from
double
/float
to an integer typeAnd finally a dozen are from a large integer type to a narrower (one
int64_t
toint32_t
for instance)20 C4996 warnings: "The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name"
13 C6340 warnings: "Mismatch on sign: 'unsigned XX' passed as Param(N) when some signed type is required in call to 'fprintf'"
Those ones are fixable via a change to the %d marker, but this might be Microsoft specific
12 C28251 warnings: "Inconsistent annotation for 'XXX': this instance has no annotations"
I'm not sure what this is about
4 C6246 warnings: "Local declaration of 'XXX' hides declaration of the same name in outer scope"
Not a big problem in and of itself, but I believe it would make the code clearer if this is fixed.
3 C4090 warnings: "different const qualifiers"
These are oversights that I believe should be fixed for clarity's sake
The remaining warnings all revolve around static analysis which suggest that there might be some out of bounds reading, null de-referencing and the like.
What I have done on my local copy is to completely disable the following warnings: 4244; 4267; 4305; 4996
This removes most of them, but I'm not too happy with this, especially the ones related to data loss.
I can spend some time looking around for fixes on most of those warnings, but I would like your opinion before I start. For instance, for the ones related to floating points literals, should I change them all to use the
f
suffix, or should I change the variable types to all usedouble
?For conversions from floating point to integer types, should I use
trunc
orround
?Any opinions are most welcome.
The text was updated successfully, but these errors were encountered: