Skip to content

Build cleanly without globally disabling warnings #873

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

Merged
merged 4 commits into from
May 9, 2017

Conversation

reuk
Copy link
Contributor

@reuk reuk commented Apr 26, 2017

Disabling warnings globally by setting 'Wno-deprecated-register' and 'Wno-sign-compare' in CXXFLAGS will silence these errors in all files, even in new code. It's better to use pragma-based warning suppression, so that warnings are only disabled in locations that won't or can't be fixed. Likewise, rather than filtering 'Wpedantic' from CXXFLAGS when building some of the solvers, it's better to disable warnings just on the problematic headers.

The goal is to create a clean build using the flags -Wall -Wpedantic -Werror on all platforms, without having to disable any errors.

@reuk reuk force-pushed the pedantic-fix branch 7 times, most recently from 08feae5 to db93002 Compare April 26, 2017 15:10
reuk added 2 commits April 26, 2017 16:29
Disabling warnings globally by setting 'Wno-deprecated-register' and
'Wno-sign-compare' in CXXFLAGS will silence these errors, even in new
code. It's better to use `pragma`-based warning suppression, so that
warnings are only disabled in locations that won't or can't be fixed.
Likewise, rather than filtering 'Wpedantic' from CXXFLAGS when building
some of the solvers, it's better to disable warnings just on the
problematic headers.
@reuk
Copy link
Contributor Author

reuk commented Apr 26, 2017

This is ready for review now (@tautschnig?)

@tautschnig
Copy link
Collaborator

Looking.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Thank you very much for this work. What I'd like to see a rationale for is the file-names-without-suffix choice. Furthermore I'm of course asking you to do even more work as those warnings have turned up actual bugs/useless checks.

index 501393d..b450b73 100644
--- a/minisat/core/Solver.cc
+++ b/minisat/core/Solver.cc
@@ -210,7 +210,7 @@ void Solver::cancelUntil(int level) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer for those changes to not be included (and similarly below), but also I'm not going to embark on bike shedding here.

unsigned has_extra : 1;
unsigned reloced : 1;
unsigned size : 27; } header;
+#include <util/pragma_push>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I disagree with the choice of not using a suffix in the file name.

assert(indent>=0);
#include <util/pragma_pop>
Copy link
Collaborator

Choose a reason for hiding this comment

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

That assert should just be removed.

assert(indent>=0);
#include <util/pragma_pop> // NOLINT(build/include)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the assert instead.

for(i=0; i < __CPROVER_JSA_MAX_ABSTRACT_NODES; ++i)
#include <util/pragma_pop>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any idea why we're getting a tautological-comparison warning here?

assert(l.loc_number>=0 && l.loc_number<loc_vector.size());
#include <util/pragma_pop>
Copy link
Collaborator

Choose a reason for hiding this comment

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

The first condition in the assertion should be removed.

assert(l.loc_number>=0 && l.loc_number<loc_vector.size());
#include <util/pragma_pop> // NOLINT(build/include)
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above.

@@ -0,0 +1,7 @@
#if defined __clang__
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason to use file names without suffix here?

@reuk
Copy link
Contributor Author

reuk commented Apr 26, 2017

Firstly, I agree that the asserts should be changed/removed.

The patch file changed because I recreated it with git (I had to add some stuff around the zero length array), but if there's another way that results in fewer changes then I'll do that instead.

The no-suffix thing is to differentiate the includes from normal headers or source files - where they don't include any declarations or definitions, it's a bit misleading to call them headers. I could give them some other extension though (.macro, .def or similar?)

@tautschnig
Copy link
Collaborator

Firstly, I agree that the asserts should be changed/removed.

Thanks in advance!

The patch file changed because I recreated it with git (I had to add some stuff around the zero length array), but if there's another way that results in fewer changes then I'll do that instead.

I had figured that you had re-generated the patch using git; what I would have done is largely the same, except I'd then only selectively add the resulting changes to the commit using git add -p. Yet only embark on this if it's quick.

The no-suffix thing is to differentiate the includes from normal headers or source files - where they don't include any declarations or definitions, it's a bit misleading to call them headers. I could give them some other extension though (.macro, .def or similar?)

I think using .inc or .def might align well with other parts of the code base. I'd reserve the suffix-less ones for the system library.

for(i=0; i < __CPROVER_JSA_MAX_ABSTRACT_NODES; ++i)
#include <util/pragma_pop.def>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having had another look at the code I do now seem to understand. For all cases in this file, could you please wrap the for loop (and also the preceding declaration by #if __CPROVER_JSA_MAX_ABSTRACT_NODES > 0 - this will resolve the need for the pragma in those loops. (This is all due to cegis/jsa/value/jsa_genetic_synthesis.h.)

@reuk
Copy link
Contributor Author

reuk commented Apr 27, 2017

I've made the suggested changes.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Thanks a lot for all the fixes!

@martin-cs
Copy link
Collaborator

martin-cs commented Apr 27, 2017 via email

@tautschnig
Copy link
Collaborator

I would strongly recommend not changing MiniSAT code.

While I do agree in general, our patches primarily reduce the number of warnings. (And this particular additional change just adds pragmas.) Is that something to be concerned about?

@kroening kroening merged commit 448853c into diffblue:master May 9, 2017
peterschrammel added a commit that referenced this pull request May 18, 2017
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.

4 participants