Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Creator doesn't know qint8 is signed
QtWS25 Last Chance

Creator doesn't know qint8 is signed

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
qtcreator
7 Posts 3 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by kshegunov
    #1

    I had to debug some code of mine when I stumbled on this (last line is the offending one):
    Debug window

    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

    Kind regards.

    EDIT:
    Okay, I posted a bug report for this. As it seems @mrjj was able to reproduce it on windows with mingw.

    Read and abide by the Qt Code of Conduct

    K 1 Reply Last reply
    0
    • kshegunovK kshegunov

      I had to debug some code of mine when I stumbled on this (last line is the offending one):
      Debug window

      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

      Kind regards.

      EDIT:
      Okay, I posted a bug report for this. As it seems @mrjj was able to reproduce it on windows with mingw.

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @kshegunov
      Is this limited to windows and MinGW respectively to a specific tool chain?

      Vote the answer(s) that helped you to solve your issue(s)

      kshegunovK 1 Reply Last reply
      0
      • K koahnig

        @kshegunov
        Is this limited to windows and MinGW respectively to a specific tool chain?

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #3

        @koahnig
        I have encountered in on Linux x64 (Debian testing 4.5.0 kernel) with Qt Creator 3.6.1 and gdb. @mrjj reproduced on Windows 10 with mingw and creator 3.6.

        PS.
        Curiously enough, char works fine. Only qint8 (which is typedefed as a signed char) is problematic.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          Be careful with char. It is implementation defined if it is a signed or unsigned value. Standard treats char, signed char and unsigned char as three separate types.
          In case of gcc/mingw it seems to be unsigned, therefore it works, but with MSVC toolchain char and signed char are 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:
          MinGW
          And here's a view from CDB with VS2015:
          MSVC

          So yeah there seems to be something wrong with GDB or how the value is presented in Qt Creator for signed char.

          kshegunovK 1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            Be careful with char. It is implementation defined if it is a signed or unsigned value. Standard treats char, signed char and unsigned char as three separate types.
            In case of gcc/mingw it seems to be unsigned, therefore it works, but with MSVC toolchain char and signed char are 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:
            MinGW
            And here's a view from CDB with VS2015:
            MSVC

            So yeah there seems to be something wrong with GDB or how the value is presented in Qt Creator for signed char.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @Chris-Kawa
            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.

            Kind regards.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              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?

              Vote the answer(s) that helped you to solve your issue(s)

              kshegunovK 1 Reply Last reply
              0
              • K koahnig

                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?

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @koahnig

                However, I consider it strange that the debugger does not distinguish as Chris is lining out.

                Well, gdb shows char as signed with a correct value of -1 (I do not know where the differences from MinGW come from). So it treats char as 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 signed char as char).

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved