This is a trivial bug where a user wanted to define NDEBUG when building genautomata, presumably trying to debug its behavior. This resulted in a unused-but-set warning which caused the build to fail.

Dario included the trivial fixes in the PR which I put through the usual bootstrap & regression test as well as compiling genautomata with NDEBUG.

Pushing to the trunk.

I'm not addressing whether or not NDEBUG is still useful. That would be Vlad's call.

Jeff

commit b81bb3ed216213fdaba82addae9fc34619ad6ec7
Author: Dario Gjorgjevski <dario.gjorgjev...@gmail.com>
Date:   Sun Feb 9 09:16:31 2025 -0700

    [PR middle-end/117263] Avoid unused-but-set warning in genautomata
    
    This is a trivial bug where a user wanted to define NDEBUG when building
    genautomata, presumably trying to debug its behavior.  This resulted in a
    unused-but-set warning which caused the build to fail.
    
    Dario included the trivial fixes in the PR which I put through the usual
    bootstrap & regression test as well as compiling genautomata with NDEBUG.
    
    Pushing to the trunk.
    
            PR middle-end/117263
    gcc/
            * genautomata.cc (output_statistics): Avoid set but unnused warnings
            when compiling with NDEBUG.

diff --git a/gcc/genautomata.cc b/gcc/genautomata.cc
index 69f856d141c..4059a229f96 100644
--- a/gcc/genautomata.cc
+++ b/gcc/genautomata.cc
@@ -9088,8 +9088,8 @@ static void
 output_statistics (FILE *f)
 {
   automaton_t automaton;
-  int states_num;
 #ifndef NDEBUG
+  int states_num;
   int transition_comb_vect_els = 0;
   int transition_full_vect_els = 0;
   int min_issue_delay_vect_els = 0;
@@ -9106,13 +9106,17 @@ output_statistics (FILE *f)
               automaton->NDFA_states_num, automaton->NDFA_arcs_num);
       fprintf (f, "    %5d DFA states,           %5d DFA arcs\n",
               automaton->DFA_states_num, automaton->DFA_arcs_num);
+#ifndef NDEBUG
       states_num = automaton->DFA_states_num;
+#endif
       if (!no_minimization_flag)
        {
          fprintf (f, "    %5d minimal DFA states,   %5d minimal DFA arcs\n",
                   automaton->minimal_DFA_states_num,
                   automaton->minimal_DFA_arcs_num);
+#ifndef NDEBUG
          states_num = automaton->minimal_DFA_states_num;
+#endif
        }
       fprintf (f, "    %5d all insns      %5d insn equivalence classes\n",
               description->insns_num, automaton->insn_equiv_classes_num);

Reply via email to