* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
@ 2023-02-07 16:46 ` pinskia at gcc dot gnu.org
2023-02-07 16:49 ` pinskia at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 54421
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54421&action=edit
testcase
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
2023-02-07 16:46 ` [Bug c/108701] " pinskia at gcc dot gnu.org
@ 2023-02-07 16:49 ` pinskia at gcc dot gnu.org
2023-02-07 16:52 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 16:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2023-02-07
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-ftabstop=4 fixes the warning.
Looks like godbolt is using 4 spaces/tab in their editor but GCC defaults to 8
spaces per tab.
I suspect you need to supply -ftabstop=4 to override GCC's defaults if you are
using 4space/tabs.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
2023-02-07 16:46 ` [Bug c/108701] " pinskia at gcc dot gnu.org
2023-02-07 16:49 ` pinskia at gcc dot gnu.org
@ 2023-02-07 16:52 ` pinskia at gcc dot gnu.org
2023-02-07 16:55 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 16:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The documentation is clear too:
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Warning-Options.html#index-Wmisleading-indentation
In the case of mixed tabs and spaces, the warning uses the -ftabstop= option to
determine if the statements line up (defaulting to 8).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (2 preceding siblings ...)
2023-02-07 16:52 ` pinskia at gcc dot gnu.org
@ 2023-02-07 16:55 ` pinskia at gcc dot gnu.org
2023-02-07 17:01 ` apjo at tuta dot io
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 16:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also once you change godbolt to be 8 spaces/tab, it becomes obvious the warning
is correct for the default.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (3 preceding siblings ...)
2023-02-07 16:55 ` pinskia at gcc dot gnu.org
@ 2023-02-07 17:01 ` apjo at tuta dot io
2023-02-07 17:02 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: apjo at tuta dot io @ 2023-02-07 17:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
apjo at tuta dot io <apjo at tuta dot io> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |FIXED
--- Comment #5 from apjo at tuta dot io <apjo at tuta dot io> ---
(In reply to Andrew Pinski from comment #2)
> -ftabstop=4 fixes the warning.
> Looks like godbolt is using 4 spaces/tab in their editor but GCC defaults to
> 8 spaces per tab.
>
> I suspect you need to supply -ftabstop=4 to override GCC's defaults if you
> are using 4space/tabs.
Interesting. I only ever use \t tabs for indentations and 1 \t == 8 spaces on
my editors, but Godbolt's default behavior is this weird thing I guess.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (4 preceding siblings ...)
2023-02-07 17:01 ` apjo at tuta dot io
@ 2023-02-07 17:02 ` pinskia at gcc dot gnu.org
2023-02-07 17:05 ` apjo at tuta dot io
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 17:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |INVALID
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (5 preceding siblings ...)
2023-02-07 17:02 ` pinskia at gcc dot gnu.org
@ 2023-02-07 17:05 ` apjo at tuta dot io
2023-02-07 17:09 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: apjo at tuta dot io @ 2023-02-07 17:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
apjo at tuta dot io <apjo at tuta dot io> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |FIXED
--- Comment #6 from apjo at tuta dot io <apjo at tuta dot io> ---
Also, thanks Andrew for the prompt reply and solution.
I had a couple follow up questions:
- How is clang getting this right? I guess it defaults to 4 space tab
(heretics!).
- So is this 'basically not a bug'?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (6 preceding siblings ...)
2023-02-07 17:05 ` apjo at tuta dot io
@ 2023-02-07 17:09 ` pinskia at gcc dot gnu.org
2023-02-07 18:24 ` apjo at tuta dot io
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 17:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |INVALID
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't know how clang is not warning. Maybe they don't take into account
spaces vs tabs ...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (7 preceding siblings ...)
2023-02-07 17:09 ` pinskia at gcc dot gnu.org
@ 2023-02-07 18:24 ` apjo at tuta dot io
2023-02-07 18:26 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: apjo at tuta dot io @ 2023-02-07 18:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
apjo at tuta dot io <apjo at tuta dot io> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |---
Status|RESOLVED |REOPENED
--- Comment #8 from apjo at tuta dot io <apjo at tuta dot io> ---
Clang can do it right so GCC should be able to too.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (8 preceding siblings ...)
2023-02-07 18:24 ` apjo at tuta dot io
@ 2023-02-07 18:26 ` pinskia at gcc dot gnu.org
2023-02-07 18:31 ` pinskia at gcc dot gnu.org
2023-02-07 18:37 ` apjo at tuta dot io
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |INVALID
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang is not even warning for -Wmisleading-indentation so it is not doing it
right or wrong there ...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (9 preceding siblings ...)
2023-02-07 18:26 ` pinskia at gcc dot gnu.org
@ 2023-02-07 18:31 ` pinskia at gcc dot gnu.org
2023-02-07 18:37 ` apjo at tuta dot io
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-07 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
That is clang does not warn about this case here (changed all tabs to spaces to
indepdent of -ftabstop option):
```
int randBytesGet()
{
int t;
while (true) {
if (true)
return 0;
#if 0
int random = rand();
#endif
t = 0;
}
return t;
}
```
GCC correctly warns about the `t = 0;` statement:
```
<source>: In function 'int randBytesGet()':
<source>:8:13: warning: this 'if' clause does not guard...
[-Wmisleading-indentation]
8 | if (true)
| ^~
<source>:13:17: note: ...this statement, but the latter is misleadingly
indented as if it were guarded by the 'if'
13 | t = 0;
| ^
```
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/108701] Incorrect -Wmisleading-indentation
2023-02-07 16:45 [Bug c/108701] New: Incorrect -Wmisleading-indentation apjo at tuta dot io
` (10 preceding siblings ...)
2023-02-07 18:31 ` pinskia at gcc dot gnu.org
@ 2023-02-07 18:37 ` apjo at tuta dot io
11 siblings, 0 replies; 13+ messages in thread
From: apjo at tuta dot io @ 2023-02-07 18:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108701
--- Comment #11 from apjo at tuta dot io <apjo at tuta dot io> ---
(In reply to Andrew Pinski from comment #10)
Okay now that looks like a clang bug. Clang is supposed to diagnose misleading
indentation like that (see: https://godbolt.org/z/1fv4rEseo).
^ permalink raw reply [flat|nested] 13+ messages in thread