Re: C++ help needed for centrifuge

2017-11-26 Thread Walter Landry
Andreas Tille  wrote:
> Hi,
> 
> On Sat, Nov 25, 2017 at 01:39:03PM -0800, Walter Landry wrote:
>> > In file included from centrifuge_build.cpp:27:0:
>> > bt2_idx.h: In static member function 'static std::pair> > Ebwt*> Ebwt::fromStrings(const 
>> > EList&, bool, int, int, bool, 
>> > int32_t, int32_t, int32_t, const string&, bool, index_t, index_t, index_t, 
>> > int, uint32_t, bool, bool, bool)':
>> > bt2_idx.h:1053:3: warning: 'template class std::auto_ptr' is 
>> > deprecated [-Wdeprecated-declarations]
>> 
>> This is only a warning, so you can ignore it.  If you are feeling
>> ambitious, the recommended fix is to replace all auto_ptr's with
>> unique_ptr's and copies with moves().
> 
> I've applied this in
> 
>
> https://anonscm.debian.org/cgit/debian-med/centrifuge.git/tree/debian/patches/fix_auto_ptr_usage_in_gcc-7.patch

I think that is OK.  If I were in charge of this code, I would convert
it from pointers to value semantics, but that would be a much larger
change.

>> Apparently, clang-modernize can
>> do this automatically.
> 
> In what package can I find clang-modernize (apt-file search did not find
> anything - but I'm currently not on my development machine).

Sorry.  It has been renamed to clang-tidy.

> Unfortunately I've hit another issue:
> 
> ...
> classifier.h:428:54: error: the value of 'rank' is not usable in a constant 
> expression
>  while((uint8_t)_hitMap[i].rank < rank) {
>   ^~~~
> classifier.h:424:21: note: 'uint8_t rank' is not const
>  uint8_t rank = 0;
>  ^~~~

That is mysterious to me.  Is that the first error?

Walter Landry



Re: C++ help needed for centrifuge

2017-11-26 Thread Andreas Tille
Hi,

On Sat, Nov 25, 2017 at 01:39:03PM -0800, Walter Landry wrote:
> > In file included from centrifuge_build.cpp:27:0:
> > bt2_idx.h: In static member function 'static std::pair > Ebwt*> Ebwt::fromStrings(const 
> > EList&, bool, int, int, bool, 
> > int32_t, int32_t, int32_t, const string&, bool, index_t, index_t, index_t, 
> > int, uint32_t, bool, bool, bool)':
> > bt2_idx.h:1053:3: warning: 'template class std::auto_ptr' is 
> > deprecated [-Wdeprecated-declarations]
> 
> This is only a warning, so you can ignore it.  If you are feeling
> ambitious, the recommended fix is to replace all auto_ptr's with
> unique_ptr's and copies with moves().

I've applied this in

   
https://anonscm.debian.org/cgit/debian-med/centrifuge.git/tree/debian/patches/fix_auto_ptr_usage_in_gcc-7.patch

> Apparently, clang-modernize can
> do this automatically.

In what package can I find clang-modernize (apt-file search did not find
anything - but I'm currently not on my development machine).

Unfortunately I've hit another issue:

...
classifier.h:428:54: error: the value of 'rank' is not usable in a constant 
expression
 while((uint8_t)_hitMap[i].rank < rank) {
  ^~~~
classifier.h:424:21: note: 'uint8_t rank' is not const
 uint8_t rank = 0;
 ^~~~
...

I tried my luck with some type castings but failed. :-(

Kind regards

  Andreas.

-- 
http://fam-tille.de



Re: C++ help needed for centrifuge

2017-11-25 Thread Walter Landry
Andreas Tille  wrote:
> Hi,
> 
> I started packaging centrifuge[1] and hit a build error which
> is most probably caused by gcc-7 incompatibility:
> 
> ...
> In file included from centrifuge_build.cpp:27:0:
> bt2_idx.h: In static member function 'static std::pair Ebwt*> Ebwt::fromStrings(const 
> EList&, bool, int, int, bool, int32_t, 
> int32_t, int32_t, const string&, bool, index_t, index_t, index_t, int, 
> uint32_t, bool, bool, bool)':
> bt2_idx.h:1053:3: warning: 'template class std::auto_ptr' is 
> deprecated [-Wdeprecated-declarations]

This is only a warning, so you can ignore it.  If you are feeling
ambitious, the recommended fix is to replace all auto_ptr's with
unique_ptr's and copies with moves().  Apparently, clang-modernize can
do this automatically.

Walter Landry



Re: C++ help needed for centrifuge

2017-11-25 Thread Alexis Murzeau
Le 25/11/2017 à 21:56, Andreas Tille a écrit :
> Hi,
> 
> I started packaging centrifuge[1] and hit a build error which
> is most probably caused by gcc-7 incompatibility:
> 
> ...
> In file included from centrifuge_build.cpp:27:0:
> bt2_idx.h: In static member function 'static std::pair Ebwt*> Ebwt::fromStrings(const 
> EList&, bool, int, int, bool, int32_t, 
> int32_t, int32_t, const string&, bool, index_t, index_t, index_t, int, 
> uint32_t, bool, bool, bool)':
> bt2_idx.h:1053:3: warning: 'template class std::auto_ptr' is 
> deprecated [-Wdeprecated-declarations]
>auto_ptr ss(new stringstream());
>^~~~
> In file included from /usr/include/c++/7/memory:80:0,
>  from bt2_idx.h:28,
>  from centrifuge_build.cpp:27:
> /usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
>template class auto_ptr;
> ^~~~
> In file included from centrifuge_build.cpp:27:0:
> bt2_idx.h:1057:3: warning: 'template class std::auto_ptr' is 
> deprecated [-Wdeprecated-declarations]
>auto_ptr fb(new FileBuf(ss.get()));
>^~~~
> In file included from /usr/include/c++/7/memory:80:0,
>  from bt2_idx.h:28,
>  from centrifuge_build.cpp:27:
> /usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
>template class auto_ptr;
> ...
> 

Hi,

You can replace auto_ptr with unique_ptr which was introduced with
C++11. std::unique_ptr is declared in the same header as auto_ptr
().

One major difference is that std::unique_ptr cannot be copied but moved
instead.
For example:
std::unique_ptr fb(new FileBuf);
std::unique_ptr fb2 = std::move(p);

After that second line, p will be empty/null and p2 will contains the
FileBuf pointer.

But in bt2_idx.h, the auto_ptr variables are not copied around so you
probably just need to replace "auto_ptr" with "unique_ptr" and that's all.


-- 
Alexis Murzeau
PGP: B7E6 0EBB 9293 7B06 BDBC  2787 E7BD 1904 F480 937F



signature.asc
Description: OpenPGP digital signature