Skip to content

enable -Wconversion and -Wsign-conversion by default #204

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

Closed
wants to merge 1 commit into from

Conversation

minad
Copy link
Member

@minad minad commented Apr 5, 2019

disable -Wsystem-headers

@minad
Copy link
Member Author

minad commented Apr 5, 2019

I also disable the warnings in the mpi tests, but this is code we might not want to touch?

@minad
Copy link
Member Author

minad commented Apr 5, 2019

@sjaeckel Note that the only changes are to the tests, no changes to the library code.

@minad
Copy link
Member Author

minad commented Apr 5, 2019

Does not build cleanly on travis. It did on my machine, I have to check.

@minad
Copy link
Member Author

minad commented Apr 5, 2019

Fortunately we have this nice travis setup which tests the different configuration 👍 Fix is on the way.

@minad
Copy link
Member Author

minad commented Apr 5, 2019

@sjaeckel About these warnings - you have to say if we really want them activated in the case of MP_8BIT and MP_16BIT since in those cases the code gets quite a bit uglier. The issue is that mp_word is smaller than int and every calculation is promoted to int which would result in many casts and for example the += operator on mp_words could not be used anymore.

My recommendation would be to activate the warnings only for sizeof(mp_word) >= 4 cases. What do you think?

@minad
Copy link
Member Author

minad commented Apr 5, 2019

My recommendation would be to activate the warnings only for sizeof(mp_word) >= 4 cases. What do you think?

I am trying this. Let's see.

@minad
Copy link
Member Author

minad commented Apr 5, 2019

@sjaeckel It works like this. Squashed and rebased.

endif

ifdef NO_CONV_WARNINGS
CFLAGS += -Wsystem-headers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not keep them enabled by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are conversion warnings in the system headers unfortunately. I also don't think Wsystem-headers is particularly useful since we cannot do anything about those issues. I never activate these warnings since they are only intended for people working on the system headers it seems.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But with NO_CONV_WARNINGS=1 for the 16 and 8 bit builds we also have the warnings activated at least sometimes in the CI, which is better than nothing :)

* no changes to the library code
* conversion issues in the demo testsuite fixed
* disable warnings in mtest since we do not want to touch mpi code
* add NO_CONV_WARNINGS and disable the warnings for 8 and 16bit limbs
  (many warnings due to int promotion if mp_word is smaller than int)
* disable Wsystem-headers if Wconversion is enabled, to avoid warnings from the system headers
@minad
Copy link
Member Author

minad commented Apr 6, 2019

@sjaeckel rebased!

@czurnieden
Copy link
Contributor

@minad My Travis is not yet running, so you still might make it first! ;-)

@minad
Copy link
Member Author

minad commented Apr 6, 2019

Hmm, for some reason the build is failing again :(

@minad
Copy link
Member Author

minad commented Apr 6, 2019

I guess it is because of xenial. Did the compiler version change?

@minad
Copy link
Member Author

minad commented Apr 6, 2019

Now it is gcc 5.4, before that it was 4.8.

@czurnieden
Copy link
Contributor

Took a closer look. You can try with some more casting inside the bit-pushing but I fear a complete change to unsigned char for all variables and values involved would be necessary.
But as I'm a strong advocate of the more warnings are resolved earlier, the less problems later I would like to keep it if possible but not at all cost, of course.

Now it is gcc 5.4, before that it was 4.8

Should not matter. Only the other way around or if it is a known bug and this warning is correct, not a bug. But that 4.8 did not recognise it is good to know because it is my default GCC, too, so I need to do the checks with a younger one.

@minad
Copy link
Member Author

minad commented Apr 6, 2019

Hmm, I am a bit inclined to give up. On my systems I am using much newer compilers (gcc 7 or 8) and very recent clangs, where these issues don't occur anymore. My interest in fighting old compilers is very limited.

I think this PR only makes sense if no heavy changes to the code are needed. For example I've read that the issue won't occur if you store the right side of |= first in an unsigned char temporary variable. But this is just stupid.

@sjaeckel
Copy link
Member

sjaeckel commented Apr 6, 2019

Should we probably simply update gcc on Travis?

@minad
Copy link
Member Author

minad commented Apr 6, 2019

My favorite solution would be to test against multiple gcc and clang versions. For example gcc 6, 7, 8 and clang 5, 6, 7. It is the question if you want to blow up the build matrix or just pick out the demo test and only build this one against multiple versions.

@sjaeckel
Copy link
Member

sjaeckel commented Apr 6, 2019

To test the standard build with all those versions should suffice IMO

@minad
Copy link
Member Author

minad commented Apr 6, 2019

Let's keep this PR open until #208 is resolved.

@czurnieden
Copy link
Contributor

xenial (Ubuntu 16.04) with GCC 5.4 is a LTS and ends in 2021. We might get more restrictive but at least the LTS distributions of the Big Players(TM) have to be supported. Ubuntu 14.04 LTS runs out this month (which runs on this machine, argh!) so GCC 4.8 can fall out if necessary.
(I think I type too slow ;-) )

minad added a commit that referenced this pull request Apr 9, 2019
Enable together with Wconversion warnings in #204 with -Wno-system-headers!
minad added a commit that referenced this pull request Apr 9, 2019
Enable together with Wconversion warnings in #204 with -Wno-system-headers!
@minad
Copy link
Member Author

minad commented Apr 19, 2019

closed via #225

@minad minad closed this Apr 19, 2019
@minad minad deleted the wconversion branch November 14, 2019 14:35
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

Successfully merging this pull request may close these issues.

3 participants