NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: toolchain/57723: -Wmisleading-indentation can warn incorrectly
The following reply was made to PR toolchain/57723; it has been noted by GNATS.
From: Jan-Benedict Glaw <jbglaw%lug-owl.de@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: toolchain-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
netbsd-bugs%netbsd.org@localhost
Subject: Re: toolchain/57723: -Wmisleading-indentation can warn incorrectly
Date: Fri, 24 Nov 2023 22:46:04 +0100
--seGp1e/yLldw2teC
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, 2023-11-24 19:20:00 +0000, Mouse <mouse%Rodents-Montreal.ORG@localhost> wrote:
> >How-To-Repeat:
> $ cat ind.c
> extern int foo(int n)
> {
> int i;
> int s;
> =09
> if (n > 1)
> { for (i=3D0,s=3D0;i<n;i++,s+=3Di) ;
> if (s > 100) s =3D 100;
> }
> else
> { s =3D 0;
> }
> return(s);
> }
> $ cc -c -o ind.o ind.c -Wmisleading-indentation
> ind.c: In function 'foo':
> ind.c:7:5: warning: this 'for' clause does not guard... [-Wmisleading-in=
dentation]
> { for (i=3D0,s=3D0;i<n;i++,s+=3Di) ;
> ^~~
> ind.c:8:5: note: ...this statement, but the latter is misleadingly inden=
ted as if it were guarded by the 'for'
> if (s > 100) s =3D 100;
> ^~
> $=20
As I happen to have recent GCC versions around:
jbglaw@lili:/var/cache/laminar/x$ ./bin/gcc --version
gcc (basepoints/gcc-14-5622-g4d7647edfd7, built at 1700496389) 14.0.0 20231=
120 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
jbglaw@lili:/var/cache/laminar/x$ ./bin/gcc -c -o /tmp/ind.o ind.c -Wmislea=
ding-indentation
ind.c: In function =E2=80=98foo=E2=80=99:
ind.c:7:5: warning: this =E2=80=98for=E2=80=99 clause does not guard... [-W=
misleading-indentation]
7 | { for (i=3D0,s=3D0;i<n;i++,s+=3Di) ;
| ^~~
ind.c:8:5: note: ...this statement, but the latter is misleadingly indented=
as if it were guarded by the =E2=80=98for=E2=80=99
8 | if (s > 100) s =3D 100;
| ^~
So it's the same message generated by up-to-date GCC versions.
(Though the source is really bad to read...)
MfG, JBG
--seGp1e/yLldw2teC
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iF0EABECAB0WIQQlDTvPcScNjKREqWEdvV51g5nhuwUCZWEZmgAKCRAdvV51g5nh
uyA0AJ4ybjTQv4bkwwsabLwqXhl4VBG/3gCfUaDhnTnMcf1QJg8FJBxm8MdSEOM=
=KOba
-----END PGP SIGNATURE-----
--seGp1e/yLldw2teC--
Home |
Main Index |
Thread Index |
Old Index