Hi all,
tl;dr: code that compiles with is_component_build=true does not compile with is_component_build=false. Fixing for the latter breaks the former. Suggestions?
Long version
I wrote this code:
struct LastWriterInfo {
raw_ptr<ClipboardHostImpl> writer;
ui::ClipboardSequenceNumberToken sequence_number;
LastWriterInfo& GetLastWriterInfo() {
static LastWriterInfo info;
which fails to compile when `is_component_build=false` with:
../../content/browser/renderer_host/clipboard_host_impl.cc:75:25: error: declaration requires an exit-time destructor [-Werror,-Wexit-time-destructors]
static LastWriterInfo info;
^
1 error generated.
However it compiles just fine with `is_component_build=true`. This is true for windows and linux.
If I change the function to:
LastWriterInfo& GetLastWriterInfo() {
static base::NoDestructor<LastWriterInfo> info;
it no longer compiles when `is_component_build=true`:
../../base/no_destructor.h:79:3: error: static assertion failed due to requirement '!std::is_trivially_destructible_v<content::(anonymous namespace)::LastWriterInfo>': T is trivially destructible; please use a function-local static of type T directly instead
static_assert(
^
../../content/browser/renderer_host/clipboard_host_impl.cc:73:45: note: in instantiation of template class 'base::NoDestructor<content::(anonymous namespace)::LastWriterInfo>' requested here
static base::NoDestructor<LastWriterInfo> info;
^
However it compiles just fine with `is_component_build=false`. Again, the same for windows and linux.
Changing the struct to be:
ClipboardHostImpl* writer = nullptr;
ui::ClipboardSequenceNumberToken sequence_number;
allows this code to compile in both cases. Is there a solution that works that also includes raw_ptr<>?