With the following two files:
// foo.cpp
#include <iostream>
#include "antithesis_sdk.h"
static void func()
{
std::cout << "func" << std::endl;
UNREACHABLE("TEST: assert 2", {});
}
void foo()
{
func();
std::cout << "foo" << std::endl;
UNREACHABLE("TEST: assert 1", {});
}
// bar.cpp
#include <iostream>
#include "antithesis_sdk.h"
static void func()
{
std::cout << "func" << std::endl;
UNREACHABLE("TEST: assert 3", {});
}
void bar()
{
func();
std::cout << "bar" << std::endl;
UNREACHABLE("TEST: assert 1", {});
}
We have two linker errors:
`.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm12EEEtlSt5arrayIcLm12EEtlA12_cLc118ELc111ELc105ELc100ELc32ELc102ELc117ELc110ELc99ELc40ELc41EEEEE' referenced in section `.text.startup[__cxx_global_var_init]' of CMakeFiles/antithesis-test.dir/bar.cpp.o: defined in discarded section `.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm12EEEtlSt5arrayIcLm12EEtlA12_cLc118ELc111ELc105ELc100ELc32ELc102ELc117ELc110ELc99ELc40ELc41EEEEE[_ZTAXtlN12_GLOBAL__N_112fixed_stringILm12EEEtlSt5arrayIcLm12EEtlA12_cLc118ELc111ELc105ELc100ELc32ELc102ELc117ELc110ELc99ELc40ELc41EEEEE]' of CMakeFiles/antithesis-test.dir/bar.cpp.o
`.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm15EEEtlSt5arrayIcLm15EEtlA15_cLc84ELc69ELc83ELc84ELc58ELc32ELc97ELc115ELc115ELc101ELc114ELc116ELc32ELc49EEEEE' referenced in section `.text.startup[__cxx_global_var_init.1]' of CMakeFiles/antithesis-test.dir/bar.cpp.o: defined in discarded section `.rodata._ZTAXtlN12_GLOBAL__N_112fixed_stringILm15EEEtlSt5arrayIcLm15EEtlA15_cLc84ELc69ELc83ELc84ELc58ELc32ELc97ELc115ELc115ELc101ELc114ELc116ELc32ELc49EEEEE[_ZTAXtlN12_GLOBAL__N_112fixed_stringILm15EEEtlSt5arrayIcLm15EEtlA15_cLc84ELc69ELc83ELc84ELc58ELc32ELc97ELc115ELc115ELc101ELc114ELc116ELc32ELc49EEEEE]' of CMakeFiles/antithesis-test.dir/bar.cpp.o
Both errors happen due to two different reasons:
- There are two asserts with the same error (
UNREACHABLE("TEST: assert 1", {}))
- There are two functions with the same name (
func)
Both cases lead to an instantiation of a variable with the type fixed_string (with the same arguments in the constructor) located in an anonymous namespace in antithesis_sdk.h.
As a workaround, the anonymous namespace can be replaced with a regular namespace.
With the following two files:
We have two linker errors:
Both errors happen due to two different reasons:
UNREACHABLE("TEST: assert 1", {}))func)Both cases lead to an instantiation of a variable with the type
fixed_string(with the same arguments in the constructor) located in an anonymous namespace inantithesis_sdk.h.As a workaround, the anonymous namespace can be replaced with a regular namespace.