On Tue, 20 Jan 2026 at 10:03, Jakub Jelinek <[email protected]> wrote:
>
> On Tue, Jan 20, 2026 at 09:52:32AM +0000, Jonathan Wakely wrote:
> > I found this a bit hard to parse. Maybe:
>
> Thanks, here is an updated version of the patch.

LGTM now, thanks.

>
> diff --git a/htdocs/gcc-16/porting_to.html b/htdocs/gcc-16/porting_to.html
> index 3bd1ff2b..74a5bf34 100644
> --- a/htdocs/gcc-16/porting_to.html
> +++ b/htdocs/gcc-16/porting_to.html
> @@ -31,9 +31,49 @@ and provide solutions. Let us know if you have suggestions 
> for improvements!
>  <!-- introduced in 0eac9cfee8cb0b21de866a04d5d59685ab35208f -->
>
>  <p>
> -Since GCC 16, <code>-Wunused-but-set-*</code> warning options no longer
> -consider preincrements and postincrements as uses, which may lead to
> -compilation failures when using <code>-Werror</code>.
> +Since GCC 16, <code>-Wunused-but-set-*</code> warning options have been
> +extended to have multiple levels controlling what kinds of uses disable
> +the warnings for variables which are otherwise unused.  Older versions of GCC
> +only implemented what has become <code>-Wunused-but-set-variable=1</code>
> +or <code>-Wunused-but-set-parameter=1</code>, while the new default
> +for <code>-Wunused-but-set-variable</code> or
> +<code>-Wunused-but-set-parameter</code> is <code>=3</code> (the new defaults
> +are also used when these warnings are enabled by
> +<code>-Wall</code> or <code>-Wextra</code>, respectively).
> +<code>=2</code> ignores pre/post inc/decrements on the variable,
> +<code>=3</code> also ignores compound assignments if the <em>LHS</em> 
> variable
> +is not also used on the <em>RHS</em>.
> +<pre><code>
> +void foo (void) {
> +  int a = 1; // -Wunused-variable warning
> +  int b = 0; // Warning for -Wunused-but-set-variable=<i>n</i> <i>n</i> 
> &gt;= 1
> +  b = 1; b = 2;
> +  int c = 0; // Warning for -Wunused-but-set-variable=<i>n</i> <i>n</i> 
> &gt;= 2
> +  ++c; c--; --c; c++;
> +  int d = 0; // Warning for -Wunused-but-set-variable=<i>n</i> <i>n</i> 
> &gt;= 3
> +  d += 4;
> +  int e = 0; // No warning, cast to void
> +  (void) e;
> +  int f = 0; // No warning, f used
> +  int g = f = 5;
> +  (void) g;
> +  int h = 0; // No warning, preincrement used
> +  int i = ++h;
> +  (void) i;
> +  int j = 0; // No warning, postdecrement used
> +  int k = j--;
> +  (void) k;
> +  int l = 0; // No warning, l used
> +  int m = l |= 2;
> +  (void) m;
> +}
> +</code></pre>
> +In order to avoid the warnings, one can either remove newly diagnosed
> +variables or parameters which aren't used except in pre/post inc/decrements
> +or compound assignments, make them used in some way, e.g. just
> +casting to <code>(void)</code>, or lowering the level of the warning.  See
> +<a 
> href=https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-but-set-variable_003d";
> +<code>-Wunused-but-set-*</code></a> documentation for more details.
>  </p>
>
>  </body>
>
>
>         Jakub
>

Reply via email to