seqan/seqan3

[IO] constructors in sam_file_output handle do not forward rvalue references to initialise_header_information()

tsnorri opened this issue · 1 comments

Does this problem persist on the current master?

  • I have verified the issue on the current master

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The constructors on lines 296 and 332 of sam_file_output take universal references to ref_ids and ref_lengths. The values passed to initialise_header_information(), however, are not forwarded. If ref_ids is an rvalue reference, ultimately sam_file_header chooses the path where a non-owning pointer to ref_ids is stored instead of the one that would copy its contents. This results in sam_file_header::ref_ids_ptr pointing to garbage.

Expected Behavior

sam_file_header::ref_ids_ptr initialised correctly even when the passed ref_ids is an rvalue. This is useful for e.g. rewriting the contents of the RNAME field.

Steps To Reproduce

Pass an rvalue for ref_ids to either of the two constructors.

Environment

- Operating system: macOS 12.6 
- SeqAn version: 404affbf6ee31aeda30ed9cc321b3700a50e5eae
- Compiler: GCC 12.2.0

Anything else?

No response

Thank you again for your quick response!