jonasmr/microprofile

memset will clear std::atomic

Closed this issue · 2 comments

On

memset(&S, 0, sizeof(S));

and
memset(pLog, 0, sizeof(*pLog));

An object of MicroProfileThreadLog is cleared.

This operation is unsafe because the std::atomic in there have no trivial copy-assignment.

/home/maarten/programming/openrw/external/microprofile/microprofile/microprofile.cpp:1221: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct MicroProfileThreadLog’ with no trivial copy-assignment; use value-initialization instead [-Wclass-memaccess]
         memset(pLog, 0, sizeof(*pLog));
                                      ^

Isn't this just the compiler being silly?
Does a platform actually exist where this is a problem?

This warning was observed on older mac builds of our project.
But I cannot reproduce this warning anymore.
Let's assume it got fixed :).
Thanks for the answer!