Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. error-[-Werror=unused-but-set-variable]
Forum Updated to NodeBB v4.3 + New Features

error-[-Werror=unused-but-set-variable]

Scheduled Pinned Locked Moved Unsolved C++ Gurus
4 Posts 3 Posters 2.3k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Abhijeet Gurav
    wrote on last edited by
    #1

    I am getting following error in cpp file while compiling qbs project -
    value store to 'variable_name' and never read [clang-analyzer-deadcode.deadstore].

    Please provide solution on this.

    JonBJ 1 Reply Last reply
    0
    • A Abhijeet Gurav

      I am getting following error in cpp file while compiling qbs project -
      value store to 'variable_name' and never read [clang-analyzer-deadcode.deadstore].

      Please provide solution on this.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Abhijeet-Gurav
      I'm afraid I don't know what "qbs project" is, but if you can change the code it's just saying an expression is assigned to a variable but that variable is not later read. Assuming it's not a coding mistake, you could remove the assignment (e.g. if it's a = b(); you could just have b();. The error message tells you this is a case of "unused-but-set-variable". If that warning were not an error (-Werror=... makes it an error) the code would compile without changing.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @JonB qbs is a project manager created a few years ago.

        @Abhijeet-Gurav as @JonB wrote, you have that variable_name somewhere in your code that is in fact never used. The solution is to search for it and remove it from your code since it's not used.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • A Offline
          A Offline
          Abhijeet Gurav
          wrote on last edited by
          #4

          Thanks @JonB and @SGaist.
          You are right, I have removed that variable and now its working fine.
          Thanks again for your help.

          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