-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IPAddress::operator= needs 32-bit aligned pointer #8817
Comments
s/Needs aligned/We need memcpy into u32 and then copy instead of reinterpret cast/? |
There is already a proper constructor which does copy the bytes one-by-one, so why should there be a reinterpret_cast or memcpy? By the way, I did a few more tests to let the compiler find all occurences of this But strangely enough the exact lines as above with So maybe the compiler already may strip this code in the optimizer step? This is the complete function: |
Can you try memcpy_P(&v4(), address, 4); |
OK.. also tried with
|
|
Let's just figure out assignments & ctors first. I'll prepare a PR. |
This is a fix. Just strange that the lines with the single used |
Basic Infos
Platform
Settings in IDE
Problem Description
See the assignment operator and other functions where the
const uint8_t*
is cast to anconst uint32_t*
Arduino/cores/esp8266/IPAddress.cpp
Lines 118 to 122 in f06710e
Arduino/cores/esp8266/IPAddress.cpp
Lines 130 to 132 in f06710e
The call is simply like this:
Where all these are part of a larger struct, which begins like this:
As can be seen, these are indeed not 32-bit aligned.
I think the build toolchain may recently have been updated, as this struct and the code that's now failing has not been changed for at least 4 years.
The same code in
IPAddress
has not been changed for a while as the current master branch has the same code for these functions as the 2.7.4 we're using.The text was updated successfully, but these errors were encountered: