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

MSVC 12: Warnings #145

Closed
Naios opened this issue Mar 28, 2015 · 6 comments
Closed

MSVC 12: Warnings #145

Naios opened this issue Mar 28, 2015 · 6 comments

Comments

@Naios
Copy link
Contributor

Naios commented Mar 28, 2015

On: 3a5573a

2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 48 bytes will be overrun; 4 bytes will be written starting at offset 48
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 24 bytes will be overrun; 4 bytes will be written starting at offset 24
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 72 bytes will be overrun; 4 bytes will be written starting at offset 72
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 72 bytes will be overrun; 4 bytes will be written starting at offset 72
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 48 bytes will be overrun; 4 bytes will be written starting at offset 48
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 72 bytes will be overrun; 4 bytes will be written starting at offset 72
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 24 bytes will be overrun; 4 bytes will be written starting at offset 24
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 96 bytes will be overrun; 4 bytes will be written starting at offset 96
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 24 bytes will be overrun; 4 bytes will be written starting at offset 24
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 72 bytes will be overrun; 4 bytes will be written starting at offset 72
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 48 bytes will be overrun; 4 bytes will be written starting at offset 48
2>c:\source\trinitycore335\dep\cppformat\format.h(2711): warning C4789: buffer 'array' of size 96 bytes will be overrun; 4 bytes will be written starting at offset 96
@Naios Naios changed the title MSVC 12: Warnings on 3a5573ac6e17cdd5c36a7cc2bf1a8cc8abfa20ce MSVC 12: Warnings Mar 28, 2015
@vitaut
Copy link
Contributor

vitaut commented Mar 28, 2015

Thanks for reporting. Could you by any chance give an example that triggers the warnings?

@amc522
Copy link

amc522 commented Mar 28, 2015

I get these same warnings when just compiling format.cc. Currently compiling with Visual Studio (12) 2013. I only get these errors when compiling for 64bit with /W4. I believe it has to do with the #define FMT_VARIADIC_ definition. I get warnings about the constant expression being evaluated
if (sizeof...(Args) > fmt::ArgList::MAX_PACKED_ARGS)
If the compiler does not remove the code inside that if block, then this line:
array[sizeof...(Args)].type = Arg::NONE;
will still be evaluated even though it will never be hit. That statement would cause a warning about going out of the array bounds.

So I dont think there is any bad or dangerous code. The compiler is reading more into it than it has to. I wrapped all the FMT_VARIADIC declarations in the following.

#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4127)
# pragma warning(disable: 4789)
#endif
...
#ifdef _MSC_VER
# pragma warning(pop)
#endif

I dont know what the right solution is though.

@Naios
Copy link
Contributor Author

Naios commented Mar 28, 2015

Naios/TrinityCore@f218d80 produces a lot of warnings with the latest cppformat (rev 3a5573a).

Probably every log message which is calling fmt::sprintf produces a warning for example:

TC_LOG_INFO("sql.updates", "Updating %s database...", DBUpdater<T>::GetTableName().c_str());

@vitaut
Copy link
Contributor

vitaut commented Mar 29, 2015

I think d238799 should fix these warnings. Unfortunately I couldn't verify the fix as the warnings are not reported in the AppVeyor build even with /W4. Thanks @amc522 and @Naios.

@amc522
Copy link

amc522 commented Mar 29, 2015

Yep, that fixed the warnings. Just tested with x86 and x64 in Visual Studio 2013 and the warnings no longer appear. Thanks!

@vitaut
Copy link
Contributor

vitaut commented Mar 29, 2015

Thank you for the confirmation, @amc522.

@vitaut vitaut closed this as completed Mar 29, 2015
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

3 participants