Solved Creator doesn't know qint8 is signed
I had to debug some code of mine when I stumbled on this (last line is the offending one):
Does anyone have an idea whether there's some configuration that I had missed (I don't remember having a problem with this before) or perhaps there's some regression in the debug helper? Ideas, suggestions?
Qt Creator version is 3.6.1
Is this limited to windows and MinGW respectively to a specific tool chain?
Be careful with
char. It is implementation defined if it is a signed or unsigned value. Standard treats
unsigned charas three separate types.
In case of gcc/mingw it seems to be unsigned, therefore it works, but with MSVC toolchain
signed charare synonymous.
Here's an example:
unsigned char bar = -1; //unsigned overflows are well defined so not an error char bazz = -1; signed char foo = -1;
Here's how GDB with MinGW sees it:
And here's a view from CDB with VS2015:
So yeah there seems to be something wrong with GDB or how the value is presented in Qt Creator for signed char.
Krzyś, I hope you'd forgive the familiarity,
I am trying to be careful. This is why I used qint8, which is properly typedefed and should be working the same on all platforms, but I do appreciate the warning! To be honest, I always thought that char should be signed (never actually checked the standard on that though), so your point is valid.
I was running into problems with char for exactly the reason @Chris Kawa is bringing up.
However, I consider it strange that the debugger does not distinguish as Chris is lining out. Or is it the conversion required by Qt creator, because the debugger communicates only in hex?
However, I consider it strange that the debugger does not distinguish as Chris is lining out.
charas signed with a correct value of
-1(I do not know where the differences from MinGW come from). So it treats
signed, but whether char is indeed signed ... not so easy to ascertain. I could only think of doing a comparison and seeing if the compiler complains:
char x = -1; unsigned char y = 3; if (y < x); //< If the compiler complains about signed unsigned comparison, we have our answer
Judging from the patch it seems that it's Cretator's problem. (it also appears that the dev uploading the patch thinks all platform Qt runs on uses