[PATCH] Changes to gcc-16/porting_to
Jakub Jelinek
jakub@redhat.com
Wed Apr 29 14:55:49 GMT 2026
On Wed, Apr 29, 2026 at 03:48:20PM +0100, Jonathan Wakely wrote:
> > @@ -59,10 +65,10 @@ void foo (void) {
> > int f = 0; // No warning, f used
> > int g = f = 5;
> > (void) g;
> > - int h = 0; // No warning, preincrement used
> > + int h = 0; // No warning, preincrement result used
> > int i = ++h;
> > (void) i;
> > - int j = 0; // No warning, postdecrement used
> > + int j = 0; // No warning, postdecrement result used
>
> If I understand correctly, this does match the intended meaning
> better, but I'd like to hear from Jakub who added this example.
I agree, but this comes straight from gcc/doc/invoke.texi, so
if it is changed, it should be changed in there as well.
> > int k = j--;
> > (void) k;
> > int l = 0; // No warning, l used
> > @@ -75,20 +81,49 @@ void foo (void) {
> > 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
> > +casting to <code>(void)</code>, or lowering the level of the warning.
> > +But note that an unused variable may indicate a coding error, where
> > +some other object was mistakenly used in its place, or a larger change
> > +was begun but left incomplete.
>
> Again, I'll leave Jakub to review this.
I think the change is fine.
Jakub
More information about the Libstdc++
mailing list