https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86293

            Bug ID: 86293
           Summary: unused variable left over (used in assert) when
                    building with -g0 -DNDEBUG [-Werror=unused-variable]
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libitm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: um at mutluit dot com
  Target Milestone: ---

when building the languages=c,c++ with "-g0 -DNDEBUG", then the following error
happens:

../../../gcc_trunk/libitm/method-serial.cc: In member function 'void
GTM::gtm_thread::serialirr_mode()':
../../../gcc_trunk/libitm/method-serial.cc:309:12: error: unused variable 'ok'
[-Werror=unused-variable]
       bool ok = disp->trycommit (priv_time);
            ^~

Of course one can get rid of it by giving also -Wno-error=unused-variable.

Hints for fixing:
As the variable gets used only in an assert statement, then the variable
definition should have "__attribute__((unused))" added:
       bool ok __attribute__((unused)) = disp->trycommit (priv_time);

Reply via email to