dmorse / simpatico

Molecular dynamics and Monte Carlo simulation package for polymeric and molecular liquids
GNU General Public License v3.0
31 stars 17 forks source link

Compilation error #45

Closed ksgustafson closed 6 years ago

ksgustafson commented 6 years ago

I am getting the following error after running 'make mcMd':

g++ -O3 -ffast-math -Wall --std=c++98 -Winline -I/Users/gust/simpatico/src -DSIMPBOND -c -o /Users/gust/simpatico/bld/serial/mcMd/neighbor/Cell.o /Users/gust/simpatico/src/mcMd/neighbor/Cell.cpp /Users/gust/simpatico/src/mcMd/neighbor/Cell.cpp:68:58: error: ordered comparison between pointer and zero ('McMd::Atom *' and 'int') if (firstClearPos > 0 && atoms[firstClearPos-1] < 0) {


1 error generated.

I changed the comparison 'atoms_[firstClearPos_-1] < 0' to 'atoms_[firstClearPos_-1] < (void *) NULL', which seems to fix the issue, but I thought I would bring it up in case this is not a good solution.
dmorse commented 6 years ago

It appears that the expression should have been `atoms[firstClearPos-1] == 0' .

I have changed the master and devel branches to reflect this. I recommend doing "git checkout Cell.cpp" to revert your change (which was not correct) and then pull a new version.

What compiler were you using? This error wasn't flagged by gnu g++ compiler or the Mac clang compiler.

Rationale: firstClearPos is the index of the first element in a contiguous block of empty elements of the array Atom* atoms[MaxAtomCell]. Empty elements in this array have 0 values, while non-empty elements contain valid pointers to Atom objects. If firstClearPos > 0 and atoms[firstClearPos-1] == 0 (i.e., is empty), then firstClearPos isn't the first empty element in the block, indicating an error.

ksgustafson commented 6 years ago

Great thanks!

I am using Apple LLVM version 9.0.0 (clang-900.0.38).