public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: add parentheses around assignments used as truth values
@ 2020-08-24 11:26 Krystian Kuźniarek
  2020-09-10 15:54 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Krystian Kuźniarek @ 2020-08-24 11:26 UTC (permalink / raw)
  To: gcc-patches, libstdc++

Hi,

A description of the problem/bug and how your patch addresses it:
I've got a small patch for -Wparentheses in system headers.

Testcases:
N/A, it's only a warning.

ChangeLog:
Sorry, contrib/mklog.py didn't quite work for me.
For some reason after instruction in line 129: "diff = PatchSet(data)" my
"diff" variable is always empty.

Bootstrapping and testing:
Tested that manually by recompling GCC, unfolding all headers with
`#include <stdc++.h>` and compiling what's been included by it.

The patch itself:
diff --git a/libstdc++-v3/include/c_global/cmath
b/libstdc++-v3/include/c_global/cmath
index b99aaf8df40..25080511722 100644
--- a/libstdc++-v3/include/c_global/cmath
+++ b/libstdc++-v3/include/c_global/cmath
@@ -1893,7 +1893,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     constexpr _Fp
     __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept
     {
-      if (__a <= 0 && __b >= 0 || __a >= 0 && __b <= 0)
+      if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
  return __t * __b + (1 - __t) * __a;

       if (__t == 1)
@@ -1902,7 +1902,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // Exact at __t=0, monotonic except near __t=1,
       // bounded, determinate, and consistent:
       const _Fp __x = __a + __t * (__b - __a);
-      return __t > 1 == __b > __a
+      return (__t > 1) == (__b > __a)
  ? (__b < __x ? __x : __b)
  : (__b > __x ? __x : __b);  // monotonic near __t=1
     }


Best regards,
Krystian

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++: add parentheses around assignments used as truth values
  2020-08-24 11:26 [PATCH] libstdc++: add parentheses around assignments used as truth values Krystian Kuźniarek
@ 2020-09-10 15:54 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-09-10 15:54 UTC (permalink / raw)
  To: Krystian Kuźniarek; +Cc: gcc-patches, libstdc++

On 24/08/20 13:26 +0200, Krystian Kuźniarek via Libstdc++ wrote:
>Hi,
>
>A description of the problem/bug and how your patch addresses it:
>I've got a small patch for -Wparentheses in system headers.

Thanks, I'll commit this one too.

>Testcases:
>N/A, it's only a warning.
>
>ChangeLog:
>Sorry, contrib/mklog.py didn't quite work for me.
>For some reason after instruction in line 129: "diff = PatchSet(data)" my
>"diff" variable is always empty.
>
>Bootstrapping and testing:
>Tested that manually by recompling GCC, unfolding all headers with
>`#include <stdc++.h>` and compiling what's been included by it.
>
>The patch itself:
>diff --git a/libstdc++-v3/include/c_global/cmath
>b/libstdc++-v3/include/c_global/cmath
>index b99aaf8df40..25080511722 100644
>--- a/libstdc++-v3/include/c_global/cmath
>+++ b/libstdc++-v3/include/c_global/cmath
>@@ -1893,7 +1893,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>     constexpr _Fp
>     __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept
>     {
>-      if (__a <= 0 && __b >= 0 || __a >= 0 && __b <= 0)
>+      if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
>  return __t * __b + (1 - __t) * __a;
>
>       if (__t == 1)
>@@ -1902,7 +1902,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       // Exact at __t=0, monotonic except near __t=1,
>       // bounded, determinate, and consistent:
>       const _Fp __x = __a + __t * (__b - __a);
>-      return __t > 1 == __b > __a
>+      return (__t > 1) == (__b > __a)
>  ? (__b < __x ? __x : __b)
>  : (__b > __x ? __x : __b);  // monotonic near __t=1
>     }
>
>
>Best regards,
>Krystian
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-10 15:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24 11:26 [PATCH] libstdc++: add parentheses around assignments used as truth values Krystian Kuźniarek
2020-09-10 15:54 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).