]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/osd: Suppress subobject-linkage warning in SelectMappingAndLayers class
authorEdwin Rodriguez <edwin.rodriguez1@ibm.com>
Thu, 7 Aug 2025 20:28:44 +0000 (16:28 -0400)
committerEdwin Rodriguez <edwin.rodriguez1@ibm.com>
Tue, 26 Aug 2025 19:55:30 +0000 (15:55 -0400)
Change SelectMapping and SelectLayers definitions to use non-static arrays of strings.

SelectMappingAndLayers::sma and SelectMappingAndLayers::sly have internal storage
duration, because it is a non-template, non-inline, non-extern const-qualified variable.

As a consequence, in each translation unit sma and sly is a different object.
And because ProgramOptionSelector takes a reference as template argument, then
ProgramOptionSelector<...> are different specializations of ProgramOptionSelector
in different translation units, because the template parameter references different objects in each.

Then, if you include the header in two different translation units, the program will
have undefined behavior, because the definitions of SelectMapping violates the one-definition
rule as they are, roughly said, not semantically identical. The compiler has no way to
decide whether SelectMapping is supposed to have ProgramOptionSelector<value1> or
ProgramOptionSelector<value2> as base class (where value1 and value2 are invented names
for the two instances of io_sequence::tester::lrc::mapping_layer_array_sizes in the
different translation units).

Fixes: https://tracker.ceph.com/issues/72482
Signed-off-by: Edwin Rodriguez <edwin.rodriguez1@ibm.com>
src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h

index d12e98416f7298915d9bd2e8be809f5a5b208d80..50b9f9ac36cdac3949fc8201166a56c009020227 100644 (file)
@@ -243,7 +243,7 @@ namespace lrc {
 // matches what index will be chosen from the layers array.
 inline static constexpr int mapping_layer_array_sizes = 15;
 
-inline static std::array<std::string, mapping_layer_array_sizes> mapping_choices = {{
+inline std::array<std::string, mapping_layer_array_sizes> mapping_choices = {{
     "_DD",
     "_DDD",
     "_DDDD",
@@ -261,7 +261,7 @@ inline static std::array<std::string, mapping_layer_array_sizes> mapping_choices
     "_D_D_DDDD",
 }};
 
-inline static std::array<std::string, mapping_layer_array_sizes> layer_choices = {{
+inline std::array<std::string, mapping_layer_array_sizes> layer_choices = {{
     "[[\"cDD\",\"\"]]",
     "[[\"cDDD\",\"\"]]",
     "[[\"cDDDD\",\"\"]]",