Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Weird warning message, it makes no sense

Weird warning message, it makes no sense

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 7 Posters 1.1k 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.
  • G Offline
    G Offline
    Guerrian
    wrote on 24 Jun 2019, 21:14 last edited by Guerrian
    #5

    dims, res, cap, v_sol and sol are just class members, they are set elsewhere in the program. It kind of makes the point.

    Linux Mint 18.3
    Qt 5.14.1
    Qt Creator 4.11.1

    J 1 Reply Last reply 25 Jun 2019, 04:29
    0
    • G Guerrian
      24 Jun 2019, 21:14

      dims, res, cap, v_sol and sol are just class members, they are set elsewhere in the program. It kind of makes the point.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 25 Jun 2019, 04:29 last edited by
      #6

      @Guerrian You did not answer second question from @SGaist
      Did you debug to see whether really all elements of tr were initialised?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 25 Jun 2019, 12:43
      1
      • J jsulm
        25 Jun 2019, 04:29

        @Guerrian You did not answer second question from @SGaist
        Did you debug to see whether really all elements of tr were initialised?

        G Offline
        G Offline
        Guerrian
        wrote on 25 Jun 2019, 12:43 last edited by Guerrian
        #7

        @jsulm dims is read in from a file it's usually 5 or 10 with:
        #define MAX_DIMS 10

        Why wouldn't all elements be initialised? The init loop will always execute and dims is not changed, there is no multithreading.

        Linux Mint 18.3
        Qt 5.14.1
        Qt Creator 4.11.1

        J 1 Reply Last reply 25 Jun 2019, 12:44
        0
        • G Guerrian
          25 Jun 2019, 12:43

          @jsulm dims is read in from a file it's usually 5 or 10 with:
          #define MAX_DIMS 10

          Why wouldn't all elements be initialised? The init loop will always execute and dims is not changed, there is no multithreading.

          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 25 Jun 2019, 12:44 last edited by
          #8

          @Guerrian said in Weird warning message, it makes no sense:

          Why wouldn't all elements be initialised, the init loop will always execute?

          Did you debug your code to see what happens? This is fastest way to find out what is happening.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply 25 Jun 2019, 13:10
          0
          • J jsulm
            25 Jun 2019, 12:44

            @Guerrian said in Weird warning message, it makes no sense:

            Why wouldn't all elements be initialised, the init loop will always execute?

            Did you debug your code to see what happens? This is fastest way to find out what is happening.

            G Offline
            G Offline
            Guerrian
            wrote on 25 Jun 2019, 13:10 last edited by
            #9

            @jsulm I don't need to debug it because it is working fine, the results are good and look correct.

            Linux Mint 18.3
            Qt 5.14.1
            Qt Creator 4.11.1

            J 1 Reply Last reply 25 Jun 2019, 13:19
            0
            • G Guerrian
              25 Jun 2019, 13:10

              @jsulm I don't need to debug it because it is working fine, the results are good and look correct.

              J Online
              J Online
              J.Hilk
              Moderators
              wrote on 25 Jun 2019, 13:19 last edited by
              #10

              @Guerrian
              I don't quite get your problem, dims is a non constant member variable, that may or may not be changed between the 2 for loops.

              the code model can't tell and is therefore warning you. If you're sure that everything will always be fine, ignore it.

              if you want to get rid of the warning. shadow it locally.

              void MMKPH::rndLcl(int seed, int its, int lcl)
              {
                  const int dims = this->dims;
                  .....
              

              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              G 1 Reply Last reply 25 Jun 2019, 13:32
              2
              • J J.Hilk
                25 Jun 2019, 13:19

                @Guerrian
                I don't quite get your problem, dims is a non constant member variable, that may or may not be changed between the 2 for loops.

                the code model can't tell and is therefore warning you. If you're sure that everything will always be fine, ignore it.

                if you want to get rid of the warning. shadow it locally.

                void MMKPH::rndLcl(int seed, int its, int lcl)
                {
                    const int dims = this->dims;
                    .....
                
                G Offline
                G Offline
                Guerrian
                wrote on 25 Jun 2019, 13:32 last edited by
                #11

                @J.Hilk said in Weird warning message, it makes no sense:

                const int dims = this->dims;

                Your shadow trick didn't work. I added this line to the top of the function and I still get the warning:

                const int dims = this->dims;
                

                Linux Mint 18.3
                Qt 5.14.1
                Qt Creator 4.11.1

                J 1 Reply Last reply 25 Jun 2019, 13:37
                0
                • G Guerrian
                  25 Jun 2019, 13:32

                  @J.Hilk said in Weird warning message, it makes no sense:

                  const int dims = this->dims;

                  Your shadow trick didn't work. I added this line to the top of the function and I still get the warning:

                  const int dims = this->dims;
                  
                  J Online
                  J Online
                  J.Hilk
                  Moderators
                  wrote on 25 Jun 2019, 13:37 last edited by
                  #12

                  @Guerrian is

                  dims == MAX_DIMS?
                  

                  otherwise you will have uninitialized entries in your array


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  G 1 Reply Last reply 25 Jun 2019, 14:14
                  1
                  • J J.Hilk
                    25 Jun 2019, 13:37

                    @Guerrian is

                    dims == MAX_DIMS?
                    

                    otherwise you will have uninitialized entries in your array

                    G Offline
                    G Offline
                    Guerrian
                    wrote on 25 Jun 2019, 14:14 last edited by Guerrian
                    #13

                    @J.Hilk Got it, finally it makes sense. So I just wrote it like this to only declare what's required:

                    int i, j, k, l, v, q, sj, r[dims], tr[dims], ti[lcl], tj[lcl];
                    

                    Linux Mint 18.3
                    Qt 5.14.1
                    Qt Creator 4.11.1

                    P 1 Reply Last reply 25 Jun 2019, 14:41
                    1
                    • G Guerrian
                      25 Jun 2019, 14:14

                      @J.Hilk Got it, finally it makes sense. So I just wrote it like this to only declare what's required:

                      int i, j, k, l, v, q, sj, r[dims], tr[dims], ti[lcl], tj[lcl];
                      
                      P Offline
                      P Offline
                      Pablo J. Rogina
                      wrote on 25 Jun 2019, 14:41 last edited by
                      #14

                      @Guerrian if your issue is solved, please don't forget to mark your post as such. Thanks.

                      Upvote the answer(s) that helped you solve the issue
                      Use "Topic Tools" button to mark your post as Solved
                      Add screenshots via postimage.org
                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0

                      14/14

                      25 Jun 2019, 14:41

                      • Login

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