Hacker News new | past | comments | ask | show | jobs | submit login

I assume you were using C++? I'm not sure what you describe is possible these days due to UB. At the very least just casting bytes received over the wire to a type is UB, so you technically need a memcpy() and hope that the compiler optimises it out.



Yes, it was C++. I was unfamiliar with the acronym "UB" so did a Google search. Does it mean "Undefined Behavior"? If I remember correctly, primitive types other than strings are memcpy'd. GetStr basically returned a char* to the right place in the buffer.


Apologies, yes Undefined Behaviour


It is not UB if it is correctly aligned.

It is UB if the underlying dynamic type is not compatible from the access type

As the bytes are coming from the kernel, you get to decide the dynamic type.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: