bamUtil icon indicating copy to clipboard operation
bamUtil copied to clipboard

Compilation doesn't work (warnings=errors)

Open Tsallagov opened this issue 7 years ago • 5 comments

I tried to compile bamutil (version with libgen included - https://genome.sph.umich.edu/w/images/7/70/BamUtilLibStatGen.1.0.13.tgz) on linux according to manual. However it didn't work because all warnings was treated as errors. I had to eddit a makefile to fix that issue:

cd bamUtil_1.0.13 \ && sed -i '/-Werror/d' libStatGen/general/Makefile

and after that bamUtil compiled without any error. That fix was not obvious for me at all, and should be either mentioned in manual or the Makefile should be eddited

Tsallagov avatar Oct 20 '17 10:10 Tsallagov

I am interested in fixing some of the warnings that you are seeing. Could you please share those (as well as your version of gcc). Thank you. I will update the documentation with information on how to disable the treatment of warnings as errors, but I would also like to fix it so it doesn't generate warnings.

mktrost avatar Oct 21 '17 12:10 mktrost

I case you still are interested in fixing warnings. This is on libStatGen-1.0.14

$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

I am seeing this issue.

Parameters.cpp -DVERSION="\"1.0.0\""
Parameters.cpp: In member function \u2018virtual void LongParameters::Status()\u2019:
Parameters.cpp:573:25: error: use of an operand of type \u2018bool\u2019 in \u2018operator++\u2019 is deprecated [-Werror=deprecated]
             legacy_count++;
                         ^~
cc1plus: all warnings being treated as errors
../Makefiles/Makefile.common:81: recipe for target 'obj/Parameters.o' failed


nahmadsen avatar Dec 11 '19 10:12 nahmadsen

Also a warning from StringBasics.cpp

StringBasics.cpp: In static member function \u2018static void String::check_vsnprintf()\u2019:
StringBasics.cpp:1391:6: warning: \u2018%5s\u2019 directive output truncated writing 9 bytes into a region of size 5 [-Wformat-truncation=]
 void String::check_vsnprintf()
      ^~~~~~
StringBasics.cpp:1398:57: note: \u2018snprintf\u2019 output 10 bytes into a destination of size 5
         int check = snprintf(temp, 5, "%5s", "VSNPRINTF");
                                                         ^

nahmadsen avatar Dec 11 '19 10:12 nahmadsen

@nahmadsen, working on other job and even other field, but thank you for answer.

Tsallagov avatar Dec 11 '19 11:12 Tsallagov

Following up ona @nahmadsen (using Ubuntu 19.10, gcc 9.2.1) I also get the following error messages:

g++  -O4 -pipe -Wall -Werror  -Wno-strict-overflow -I../include -I.   -D__ZLIB_AVAILABLE__ -D_FILE_OFFSET_BITS=64 -D__STDC_LIMIT_MACROS  -o obj/Chromosome.o -c Chromosome.cpp -DVERSION="\"1.0.0\""
Chromosome.cpp: In constructor ‘Chromosome::Chromosome(const string&, unsigned int, bool)’:
Chromosome.cpp:42:15: error: ‘*<unknown>.Chromosome::gs’ is used uninitialized in this function [-Werror=uninitialized]
   42 |     if (this->gs) delete gs;
      |         ~~~~~~^~
cc1plus: all warnings being treated as errors
g++  -std=c++0x -pg -pipe -Wall  -I../../libStatGen/include -I.   -D__ZLIB_AVAILABLE__ -D_FILE_OFFSET_BITS=64 -D__STDC_LIMIT_MACROS -DDATE="\"do 13 feb 2020 16:43:11 CET\"" -DVERSION="\"1.0.14\"" -DUSER="\"lennart\""  -o ../bin/profile/bam ../obj/profile/BamExecutable.o ../obj/profile/Validate.o ../obj/profile/Convert.o ../obj/profile/Diff.o ../obj/profile/DumpHeader.o ../obj/profile/SplitChromosome.o ../obj/profile/WriteRegion.o ../obj/profile/DumpIndex.o ../obj/profile/ReadIndexedBam.o ../obj/profile/DumpRefInfo.o ../obj/profile/Filter.o ../obj/profile/ReadReference.o ../obj/profile/Revert.o ../obj/profile/Squeeze.o ../obj/profile/FindCigars.o ../obj/profile/Stats.o ../obj/profile/PileupElementBaseQCStats.o ../obj/profile/ClipOverlap.o ../obj/profile/MateMapByCoord.o ../obj/profile/SplitBam.o ../obj/profile/TrimBam.o ../obj/profile/MergeBam.o ../obj/profile/PolishBam.o ../obj/profile/GapInfo.o ../obj/profile/Logger.o ../obj/profile/Bam2FastQ.o ../obj/profile/Dedup.o ../obj/profile/Dedup_LowMem.o ../obj/profile/Prediction.o ../obj/profile/LogisticRegression.o ../obj/profile/MathCholesky.o ../obj/profile/HashErrorModel.o ../obj/profile/Recab.o ../obj/profile/OverlapHandler.o ../obj/profile/OverlapClipLowerBaseQual.o ../obj/profile/ExplainFlags.o ../obj/profile/Main.o  ../../libStatGen/libStatGen_profile.a -lm -lz  
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:267:35: warning: catching polymorphic type ‘class std::runtime_error’ by value [-Wcatch-value=]
  267 |         catch (std::runtime_error e)
      |                                   ^
Main.cpp:292:35: warning: catching polymorphic type ‘class std::runtime_error’ by value [-Wcatch-value=]
  292 |         catch (std::runtime_error e)
      |                                   ^

This last one is repeated a couple of times in Main.cpp.

Note that compilation is successful when running

USER_WARNINGS="" make all

lckarssen avatar Feb 13 '20 15:02 lckarssen