This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/69415] -Wmisleading-indentation warns on "if (__b < __a) return __b; return __a;"


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69415

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #13 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> In the resipMin example the braces are on separate lines. My guess is that's
> fairly uncommon, but the warning doesn't seem helpful in that case anyway:
> nobody is going to think the second return is guarded by the if, because it
> immediately follows another return.
> 
> I think the returns in this example make it very different from:
> 
>   if (b) do_something(); do_something_else();
> 
> Also, when the entire function body is on a single line (except possibly the
> braces) it's debatable whether there is any "indentation" at all, let alone
> misleading indentation :-)

Would it be a reasonable tradeoff then to suppress the warning if the body of
the one-liner is a jump statement (return, goto, break, continue)?

Note that e.g. bdwgc uses this coding style heavily and we emit a lot of
false-positives about it.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]