seqan / seqan3

The modern C++ library for sequence analysis. Contains version 3 of the library and API docs.
https://www.seqan.de
Other
411 stars 82 forks source link

compiling with _GLIBCXX_DEBUG gives errors #3221

Closed notestaff closed 10 months ago

notestaff commented 10 months ago

Does this problem persist on the current master?

Is there an existing issue for this?

Current Behavior

Compiling a seqan3-dependent program with -D_GLIBCXX_DEBUG (debug mode) gives errors that don't happen without debug mode:

In file included from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/marti2/include/marti2/marti2_utils.hpp:17,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/marti2/marti2_utils.cpp:9:
/data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/nucleotide/dna4.hpp: In function 'constexpr seqan3::dna4_vector seqan3::literals::operator""_dna4(const char*, std::size_t)':
/data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/nucleotide/dna4.hpp:260:17: error: variable 'r' of non-literal type 'seqan3::dna4_vector' {aka 'std::__debug::vector<seqan3::dna4>'} in 'constexpr' function only available with '-std=c++2b' or '-std=gnu++2b'
  260 |     dna4_vector r;
      |                 ^
In file included from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/x86_64-conda-linux-gnu/include/c++/12.3.0/vector:74,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/x86_64-conda-linux-gnu/include/c++/12.3.0/functional:62,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/submodules/cereal/include/cereal/cereal.hpp:35,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/submodules/cereal/include/cereal/archives/binary.hpp:32,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/core/concept/cereal.hpp:20,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/concept.hpp:18,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/views/char_strictly_to.hpp:17,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/marti2/marti2_utils.cpp:2:
/data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/x86_64-conda-linux-gnu/include/c++/12.3.0/debug/vector:117:11: note: 'std::__debug::vector<seqan3::dna4>' is not literal because:
  117 |     class vector
      |           ^~~~~~
/data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/x86_64-conda-linux-gnu/include/c++/12.3.0/debug/vector:117:11: note:   'std::__debug::vector<seqan3::dna4>' does not have 'constexpr' destructor
In file included from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/aminoacid/all.hpp:70,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/all.hpp:185,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/marti2/include/marti2/marti2_defs.hpp:11,
                 from /data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/marti2/include/marti2/marti2_utils.hpp:20:
/data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/aminoacid/aa10li.hpp: In function 'constexpr seqan3::aa10li_vector seqan3::literals::operator""_aa10li(const char*, size_t)':
/data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/include/seqan3/alphabet/aminoacid/aa10li.hpp:233:19: error: variable 'r' of non-literal type 'seqan3::aa10li_vector' {aka 'std::__debug::vector<seqan3::aa10li>'} in 'constexpr' function only available with '-std=c++2b' or '-std=gnu++2b'
  233 |     aa10li_vector r;
      |                   ^
/data/ilya/iwork/marti/tmp/wtree/is-231002-1155-marti-cpp/build/marti2_envs/x86_64-conda-linux-gnu/include/c++/12.3.0/debug/vector:117:11: note: 'std::__debug::vector<seqan3::aa10li>' is not literal because:
  117 |     class vector
      |           ^~~~~~

Expected Behavior

We'd like to compile a seqan3-dependent program under C++20 standard in debug mode, without errors.

Steps To Reproduce

Add -D_GLIBCXX_DEBUG when compiling.

Environment

`
uname -a
Linux bpb23-acc 5.4.0-136-generic #153-Ubuntu SMP Thu Nov 24 15:56:58 UTC 2022 x86_64 GNU/Linux

$CXX --version
x86_64-conda-linux-gnu-c++ (conda-forge gcc 12.3.0-2) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
conda env export | grep seqan3
  - seqan3=3.3.0=hdfd78af_0
`

Anything else?

As always, thanks for your work on seqan!

@eseiler

eseiler commented 10 months ago

Hey there,

I'll look at this on Wednesday (still on holiday today and tomorrow).

It should only use constexpr vectors if the compiler supports it and our nightlies with glibcxx_debug also work, but they might just not cover your use case.

Do you have a minimal example that fails to compile? I. E., how do you use the alphabet vector?

SGSSGene commented 10 months ago

I can confirm this bug on godbolt with the newest seqan version (it works with seqan 3.2.0): https://godbolt.org/z/fzfTqfdbq

SGSSGene commented 10 months ago

I believe this is a bug in gcc/libstdc++ We can reproduce it here (without seqan): https://godbolt.org/z/oTfhEWrvd

I found this entry on bugzilla, showing at least one person is aware of this issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104748

To solve this, we don't guarentee that ""_dna is constexpr, we could put in another switch, removing the constexpr if -D_GLIBCXX_DEBUG is set, what do you think @eseiler ?

SGSSGene commented 10 months ago

I suggested following fix: https://github.com/seqan/seqan3/pull/3222