Skip to content
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

Warning in XCode 7 #28

Closed
beemaster opened this issue Sep 29, 2015 · 4 comments
Closed

Warning in XCode 7 #28

beemaster opened this issue Sep 29, 2015 · 4 comments

Comments

@beemaster
Copy link
Contributor

After updating to XCode 7 I have following warning:

tinyformat.h:864:27: error: field 'm_formatterStore' is uninitialized when used here [-Werror,-Wuninitialized]
            : FormatList(&m_formatterStore[0], N),

I wish I could do a pull request but I can not wrap my head around how this could be fixed.

@c42f
Copy link
Owner

c42f commented Sep 30, 2015

This probably happens because the value m_formatterStore[0] is indeed uninitialized at that point (it gets initialized on the next line). However, the warning is spurious because the address &m_formatterStore[0] is perfectly well defined, and is not dereferenced until later. What happens if you replace &m_formatterStore[0] with m_formatterStore.data()?

If that doesn't help, another option is to disable the -Wuninitialized warning on this one line, using #pragma GCC diagnostic ignored "-Wuninitialized", the associated pragma warning push/pop dance, and #ifdefs for the specific version of clang. It'll be ugly ;-)

@c42f
Copy link
Owner

c42f commented Mar 25, 2016

On second thoughts, taking &m_formatterStore[0] when the store is a std::array is technically an error (albeit a harmless one), since it calls operator[] on an uninitialized object. I think the better solution here is to just revert to a plain old C style array for m_formatterStore where taking a reference is clearly harmless.

I've done this and it seems to pass all the tests on windows VS2013,VS2015 and linux gcc-4.8, clang-3.7. I did manage to reproduce your warnings with clang-3.7 on linux so hopefully this will also fix your problems on xcode 7. Let me know how it works for you.

@beemaster
Copy link
Contributor Author

Yes, it helped. Thanks!

@c42f
Copy link
Owner

c42f commented Apr 22, 2016

Great, thanks for the follow up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants