-
Notifications
You must be signed in to change notification settings - Fork 3
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
Clang compliance #90
Clang compliance #90
Conversation
…dentified by Clang and Clang++. They are all minor. The result passes 'ctest -L long' but pyEXP-example notebooks have not been run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very explicit definitions now, I like it!
Not sure how this will play with pybind11fix
. I'm tempted to try merging this into pybind11fix
first?
include/massmodel.H
Outdated
@@ -188,13 +188,13 @@ public: | |||
virtual double get_dpot2(const double) = 0; | |||
virtual void get_pot_dpot(const double, double&, double&) = 0; | |||
|
|||
double get_mass(const double x1, const double x2, const double x3) | |||
double get_mass(const double x1, const double x2, const double x3) override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice -- I didn't know about override
before. Definitely reduces the warnings!
utils/ICs/gensph.cc
Outdated
double a[NUMR], b[NUMR], c[NUMR]; | ||
fftw_complex A[NUMR], B[NUMR], C[NUMR]; | ||
std::vector<double> a(NUMR), b(NUMR), c(NUMR); | ||
std::vector<fftw_complex> A(NUMR), B(NUMR), C(NUMR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was causing problems for me:
error: object expression of non-scalar type 'double[2]' cannot be used in a pseudo-destructor expression
I think this is because typedef double fftw_complex[2];
is the under-the-hood definition in FFTW, which is causing a problem when passed to std::vector
as MacOS handles it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be handled using a std::unique_ptr<fftw_complex>
instead. But a bit surprised that Mac and Linux would be different here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From RTFM, fftw
knows about C complex, so I think we can get rid of fftw_complex
in favor of std::complex
which is compatible with C complex. That is, std::vector<std::complex<double>>
rather than std::vector<fftw_complex>
. I'll try it now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this passes CI, it seems unlikely it will cause trouble for anyone else. I think it's appropriate to try a merge of this PR after someone else checks that these changes make sense.
Now also addressing #53. |
This branch has |
Please try the latest refactoring on your Mac, when you have a chance. TL;DR: I agree with the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks out for me, thanks!
All |
Summary
This addresses all the warnings generated by
clang++
from PR #85 and includes that PR.There are three types of fixes:
std::vector<T>
or astd::unique_ptr<T[]>
to automatically manage memory.std::shared_ptr
to do a dynamic cast for a type was flagged by the compiler as "expressions with side-effects", even though I think they are probably okay . These were switched to dynamic casts to pointers to types, with no "side effects".The compiled code passes
ctest -L long
tests. Several of these changes are inexpui
code. While I do not think that the likelihood of breaking code is low (since most of these changes are in memory management for buffers), I might be good to check this code against thepyEXP-examples/Tutorials
notebooks for verification.