This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/69415] New: -Wmisleading-indentation warns on "if (__b < __a) return __b; return __a;"
- From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 21 Jan 2016 16:12:56 +0000
- Subject: [Bug c/69415] New: -Wmisleading-indentation warns on "if (__b < __a) return __b; return __a;"
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69415
Bug ID: 69415
Summary: -Wmisleading-indentation warns on "if (__b < __a)
return __b; return __a;"
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
This Debian bug report for "resiprocate":
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812005
has:
> In file included from ../rutil/Data.hxx:13:0,
> from ../rutil/Log.hxx:4,
> from ../rutil/SysLogBuf.hxx:12,
> from SysLogStream.cxx:1:
> ../rutil/compat.hxx: In function 'const _Tp& resip::resipMin(const _Tp&, const _Tp&)':
> ../rutil/compat.hxx:187:31: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
> if (__b < __a) return __b; return __a;
> ^~~~~~
>
> ../rutil/compat.hxx:187:4: note: ...this 'if' clause, but it is not
> if (__b < __a) return __b; return __a;
> ^~
The code in question is:
if (__b < __a) return __b; return __a;
(I wasn't able to locate it within https://github.com/resiprocate/resiprocate )
Arguably this conditional could use an "else", but this construct appears to be
present in an old version of our STL implemenation, at least e.g.:
https://gcc.gnu.org/ml/libstdc++/2003-02/txt00002.txt
How common is this construct?
Should we warn about it?