What's the correct way to write the code below? I have a memory managing resource that provides me with pointer to char array, but I need to work with array of uint32_t. How can I work around the strict aliasing rule? I understand that with a single object it's advised just to copy the contents with memcpy but that solution is not acceptable for an array of objects.
char* ptr = manager()->Allocate(1000 * sizeof(uint32_));
uint32_t* u32ptr = reinterpret_cast<uint32_t*>(ptr);
....
u32ptr[x] = y;
Aucun commentaire:
Enregistrer un commentaire