Skip to content

Conversation

bgranzow
Copy link
Contributor

  • Modify cmake/bob.cmake to use '-Wall -Werror -Wextra' when using clang, clang's -Weverything would take a substantial effort to clean up warnings

  • Eliminate the following compilation errors:

  • Compilation still worked w/ GCC, so that's cool I guess

In file included from /Users/bngranz/src/core/ma/maFaceSplit.cc:12:
/Users/bngranz/src/core/ma/maFaceSplit.h:44:10: error: private field 'shouldCollect' is not used [-Werror,-Wunused-private-field]
    bool shouldCollect[4];
/Users/bngranz/src/core/phasta/phRestart.cc:384:43: error: while loop has empty body [-Werror,-Wempty-body]
  while( readAndAttachField(in,f,m,swap) );
                                          ^
/Users/bngranz/src/core/phasta/phRestart.cc:384:43: note: put the semicolon on a separate line to silence this warning
/Users/bngranz/src/core/phasta/phBubble.cc:25:23: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
  sprintf(bubblefname,bubbleFileName.c_str());
                      ^~~~~~~~~~~~~~~~~~~~~~
/Users/bngranz/src/core/phasta/phBubble.cc:25:23: note: treat the string as an argument to avoid this
  sprintf(bubblefname,bubbleFileName.c_str());
/Users/bngranz/src/core/phasta/phiotimer.cc:145:29: error: format specifies type 'unsigned long long' but the argument has type 'size_t'
      (aka 'unsigned long') [-Werror,-Wformat]
        getFileName(), key, min, max, avg);
                            ^~~
/Users/bngranz/src/core/phasta/phiotimer.cc:145:34: error: format specifies type 'unsigned long long' but the argument has type 'size_t'
      (aka 'unsigned long') [-Werror,-Wformat]
        getFileName(), key, min, max, avg);
                                 ^~~
/Users/bngranz/src/core/phasta/phiotimer.cc:217:68: error: format specifies type 'unsigned long long' but the argument has type 'size_t'
      (aka 'unsigned long') [-Werror,-Wformat]
    fprintf(stderr, "%" PRIu64 " us measured as %" PRIu64 " us\n", us, elapsed);
                     ~~~                                           ^~
/Users/bngranz/src/core/phasta/phiotimer.cc:217:72: error: format specifies type 'unsigned long long' but the argument has type 'size_t'
      (aka 'unsigned long') [-Werror,-Wformat]
    fprintf(stderr, "%" PRIu64 " us measured as %" PRIu64 " us\n", us, elapsed);

@bgranzow bgranzow requested a review from cwsmith July 14, 2018 19:07
Copy link
Contributor

@cwsmith cwsmith left a comment

Choose a reason for hiding this comment

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

looks good - thank you!

@cwsmith cwsmith merged commit 2aa19c4 into SCOREC:develop Jul 15, 2018
@cwsmith
Copy link
Contributor

cwsmith commented Jul 16, 2018

Ehhh. So on our rhel7 system with gcc 7.3 this built and ran without issue. But, on the older debian squeeze nightly testing system w/ gcc 4.4.5 (avatar) it fails with:

/fasttmp/cwsmith/nightlyBuilds/repos/SCOREC/phasta/phiotimer.cc: In function 'void printMinMaxAvgSzt(const char*, size_t)':
/fasttmp/cwsmith/nightlyBuilds/repos/SCOREC/phasta/phiotimer.cc:145: error: format '%lu' expects type 'long unsigned int', but argument 5 has type 'long long int'
/fasttmp/cwsmith/nightlyBuilds/repos/SCOREC/phasta/phiotimer.cc:145: error: format '%lu' expects type 'long unsigned int', but argument 6 has type 'long long int'
/fasttmp/cwsmith/nightlyBuilds/repos/SCOREC/phasta/phiotimer.cc: In function 'void phastaio_printStats()':
/fasttmp/cwsmith/nightlyBuilds/repos/SCOREC/phasta/phiotimer.cc:218: error: format '%lu' expects type 'long unsigned int', but argument 3 has type 'long long int'
/fasttmp/cwsmith/nightlyBuilds/repos/SCOREC/phasta/phiotimer.cc:218: error: format '%lu' expects type 'long unsigned int', but argument 4 has type 'long long int'
make[2]: *** [phasta/CMakeFiles/ph.dir/phiotimer.cc.o] Error 1

Based on the description I assume you were building with clang on OSX? If so, which version? My laptop has:
Apply LLVM version 9.1.0 (clang-902.0.39.1)

@bgranzow
Copy link
Contributor Author

Lame

Yea, I was compiling on clang w/

Apple LLVM version 9.0.0 (clang-900.0.39.2)

@bgranzow
Copy link
Contributor Author

For what it's worth, I compiled it on jenga w/ gcc 4.9.2.

Maybe this stack overflow post is useful?
https://stackoverflow.com/questions/2524611/how-can-one-print-a-size-t-variable-portably-using-the-printf-family

cwsmith added a commit that referenced this pull request Jul 21, 2018
again :)
@cwsmith
Copy link
Contributor

cwsmith commented Jul 21, 2018

I cheated and used cerr instead of fprintf. Please let me know if you hit any errors on OSX.

@cwsmith cwsmith mentioned this pull request Jul 21, 2018
@bgranzow
Copy link
Contributor Author

Nice! Pretty sure that's the right way to do it.

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.

2 participants