Skip to content
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

Need to set old C++ standard on recent Debian platforms. #1

Open
charles-plessy opened this issue Nov 8, 2017 · 4 comments
Open

Need to set old C++ standard on recent Debian platforms. #1

charles-plessy opened this issue Nov 8, 2017 · 4 comments

Comments

@charles-plessy
Copy link

Hello,

When compiling SlideSort on a recent Debian (9.1/Stretch) that uses GCC 6.3.0, I get the following error:

mstree.cpp:228:11: error: no match for ‘operator==’ (operand types are ‘std::ofstream {aka std::basic_ofstream<char>}’ and ‘long int’)
   if(dFile==NULL){
           ^

As a quick workaround, I could bypass it by using GCC's option -std=c++98 as follows:

diff --git a/SS_v2/Makefile.gcc b/SS_v2/Makefile.gcc
index 3bb22d6..b1b8546 100644
--- a/SS_v2/Makefile.gcc
+++ b/SS_v2/Makefile.gcc
@@ -10,7 +10,7 @@ objs = blockutil.o pssExecutor.o parallelslidesort.o pmscls.o box.o seq.o comlin
 CXX = g++
 AR = ar
 
-CFLAGS =  -O3 -fPIC -fopenmp
+CFLAGS =  -O3 -fPIC -fopenmp -std=c++98
 
 .SUFFIXES: .cpp .o
 
diff --git a/mst_v2/Makefile.gcc b/mst_v2/Makefile.gcc
index d38f34d..882a6d8 100644
--- a/mst_v2/Makefile.gcc
+++ b/mst_v2/Makefile.gcc
@@ -7,7 +7,7 @@ objs = tree.o mstree.o blockutil.o pssExecutor.o parallelslidesort.o box.o seq.o
 CXX = g++
 AR = ar
 
-CFLAGS = -O3 -fPIC -Wall -L./ -I./ -fopenmp
+CFLAGS = -O3 -fPIC -Wall -L./ -I./ -fopenmp -std=c++98
 
 .SUFFIXES: .cpp .o
 

Have a nice day,

--
Charles Plessy, RIKEN Yokohama, Japan.

@mcfrith
Copy link

mcfrith commented Nov 10, 2017

I think this is the long-term fix:

if(!dFile){

@charles-plessy
Copy link
Author

charles-plessy commented Nov 10, 2017

Thanks Martin,

with the following patch, the code compiles as well as with the previous patch.

diff --git a/mst_v1/mstree.cpp b/mst_v1/mstree.cpp
index d4b3254..7b2f6a8 100644
--- a/mst_v1/mstree.cpp
+++ b/mst_v1/mstree.cpp
@@ -217,7 +217,7 @@ Contact: shimizu-kana@aist.go.jp \n";
 
        if(isPairOut || isAlnOut){
                pFile.open(pairFname);
-               if(pFile==NULL){
+               if(!pFile){
                        cerr<<"ERROR: output file for alignment is not found\nPlease use -F filename\n";
                        exit(1);
                }
@@ -225,7 +225,7 @@ Contact: shimizu-kana@aist.go.jp \n";
 
        if(isDegreeOut){
                dFile.open(degreeFname);
-               if(dFile==NULL){
+               if(!dFile){
                        cerr<<"ERROR: output file for degree is not found\nPlease use -R filename\n";
                        exit(1);
                }

Unfortunately, in both cases the ssmt_v2 program segfaults in some corner case situations, for instance with the following data and commands:

cat > test.fa << _END_
>seq1:umi=TTAACTGG
TTAACTGGCATCCAGAACGAGCTATCGA
>seq2:umi=AGGTTATA
AGGTTATACATCCAGAACGAGCTATCGA
>seq3:umi=TGAGGTAA
TGAGGTAACATCCAGAACGAGCTATCGA
>seq4:umi=TTAAGACA
TTAAGACACATCCAGAACGAGCTATCGA
_END_
./mst_v2/ssmst_v2 -u -d 0 -g 0.5 -Z -U -i test.fa

The segmentation fault does not happen on a computer using GCC version 4.9.4, where the code could compile without patch.

Edit (25/12/2017): corrected the patch, which contained dFile==NULL, which compiled but was wrong. See StackOverflow for an explanation on Martin's suggestion to use if(!dFile).

@charles-plessy
Copy link
Author

Here the output of valgrind, after patching the source as above plus as follows, and running the following test command:

valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./mst_v2/ssmst_v2 -u -d 0 -g 0.5 -Z -U -i test.fa

diff --git a/SS_v2/Makefile.gcc b/SS_v2/Makefile.gcc
index 3bb22d6..23068fd 100644
--- a/SS_v2/Makefile.gcc
+++ b/SS_v2/Makefile.gcc
@@ -10,7 +10,7 @@ objs = blockutil.o pssExecutor.o parallelslidesort.o pmscls.o box.o seq.o comlin
 CXX = g++
 AR = ar
 
-CFLAGS =  -O3 -fPIC -fopenmp
+CFLAGS =  -g -O0 -fPIC -fopenmp
 
 .SUFFIXES: .cpp .o
 
diff --git a/mst_v2/Makefile.gcc b/mst_v2/Makefile.gcc
index d38f34d..e75249d 100644
--- a/mst_v2/Makefile.gcc
+++ b/mst_v2/Makefile.gcc
@@ -7,7 +7,7 @@ objs = tree.o mstree.o blockutil.o pssExecutor.o parallelslidesort.o box.o seq.o
 CXX = g++
 AR = ar
 
-CFLAGS = -O3 -fPIC -Wall -L./ -I./ -fopenmp
+CFLAGS = -g -O0 -fPIC -Wall -L./ -I./ -fopenmp
 
 .SUFFIXES: .cpp .o
 

@charles-plessy
Copy link
Author

Good news, no segfault after compiling with gcc 8.3.0!

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

No branches or pull requests

2 participants