问题
I am getting this warning for my logic -
Logic :
uint8_t *m_data;
uint32_t* datap = (uint32_t*)m_data;
Warning:
Info 826: Suspicious pointer-to-pointer conversion (area too small)
As it is required to typecast the value during assignment ..And i am not feeling there is something wrong in given line of code ..how I can suppress this warning or remove it from build
回答1:
That's not a correct cast, you're attempting to interpret a pointer to a byte as a pointer to 4 bytes, and can lead to unexpected results. If uint32_t
has different alignment requirements than uint8_t
, you might even get a different value of the pointer, and also what it points to. If you want to convert the value, just do:
uint32_t datap;
datap = static_cast<uint32_t>(*m_data);
来源:https://stackoverflow.com/questions/21552209/suspicious-pointer-to-pointer-conversion-area-too-small