-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fix String initialization in GCC 4.8.5 #1977
Conversation
…ly ignores static union initailizer
This is exactly the issue mentioned in #1817. (BTW: I can't express enough my appreciation for the gdbstub integration, which was incredible helpful in tracking this down.) However, may I suggest to take care of another minor issue within this PR: int indexOf(const char* s2_buf, size_t fromIndex = 0, size_t s2_len = 0) const; This breaks common patterns like My suggestion would be something like this: int indexOf(const char* s2_buf, size_t fromIndex, size_t s2_len) const;
int indexOf(const char* s2_buf, size_t fromIndex = 0) const
{
return indexOf(s2_buf, fromIndex, strlen(s2_buf));
} |
Tested and confirmed to do the work. @mikee47 when you have time check @aemseemann comment. |
@aemseemann Yes, I agree yours is a much better way to handle this - thanks for pointing it out. I'll make the change. |
@mikee47 Thanks a lot for your help! |
I broke it so I should fix it! |
Thanks for the fix, my 'develop' code is working again |
This PR fixes the instablity problems related to the
String
class since #1951. The problem is present only in Linux with GCC 4.8.5, which silently ignores the union intializer and member variables are left un-initialised at construction time.This is the initializer which causes the problem:
Simplifying it has no effect:
So it seems something to be avoided generally.
The solution, therefore, is to add a default constructor which does the initialisation and ensure it's used by all the other constructors.
This has been tested using
HostTests
build and flashed in a Linux VM.Note that this PR also addresses another GCC 4.8.5 annoyance in its limited ability to handle constexpr functions. This means the HostTests can be built in Linux.