joboccara/pipes

`optional` storage may be misaligned

TartanLlama opened this issue · 5 comments

The implementation of optional in helpers stores objects in a character buffer, but the buffer may not meet the alignment requirements for types stored in it.

Thanks!
I've made a fix for this. Does it look OK to you now?

I'd get rid of the [1], but otherwise yeah!

Ok thanks. For the record, I can't seem to get rid of it and still specify I'd like one T in my buffer: the code doesn't compile if I just remove [1]. Maybe it's because I'm not familiar with aligned_storage, but it's no big issue anyway.

If you remove the [1] you'd also need to explicitly take the address of m_object when you reinterpret_cast or placement new into it.

Oh, right. It's done now (commit). Thanks a lot, I wasn't familiar with aligned_storage before.