public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/101965] New: check in charconv is vacuously true
@ 2021-08-18 18:19 barry.revzin at gmail dot com
2021-08-19 10:37 ` [Bug libstdc++/101965] " redi at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: barry.revzin at gmail dot com @ 2021-08-18 18:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
Bug ID: 101965
Summary: check in charconv is vacuously true
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
When investigating PVS-Studio in our codebase, it flagged this check in
charconv:
322 template<typename _Tp>
323 __detail::__integer_to_chars_result_type<_Tp>
324 __to_chars_i(char* __first, char* __last, _Tp __value, int __base =
10)
325 {
326 __glibcxx_assert(2 <= __base && __base <= 36);
327
328 using _Up = __detail::__unsigned_least_t<_Tp>;
329 _Up __unsigned_val = __value;
330
331 if (__first == __last) [[__unlikely__]]
332 return { __last, errc::value_too_large };
333
334 if (__value == 0)
335 {
336 *__first = '0';
337 return { __first + 1, errc{} };
338 }
339
340 if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value)
341 if (__value < 0)
342 {
343 if (__builtin_expect(__first != __last, 1))
344 *__first++ = '-';
345 __unsigned_val = _Up(~__value) + _Up(1);
346 }
347
348 switch (__base)
349 {
350 case 16:
On line 343, __first is never equal to __last. If it were, we would've returned
on line 332.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/101965] check in charconv is vacuously true
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
@ 2021-08-19 10:37 ` redi at gcc dot gnu.org
2021-08-19 10:38 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-19 10:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2021-08-19
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/101965] check in charconv is vacuously true
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
2021-08-19 10:37 ` [Bug libstdc++/101965] " redi at gcc dot gnu.org
@ 2021-08-19 10:38 ` redi at gcc dot gnu.org
2021-08-19 13:57 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-19 10:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
At least I got the branch prediction right though.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/101965] check in charconv is vacuously true
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
2021-08-19 10:37 ` [Bug libstdc++/101965] " redi at gcc dot gnu.org
2021-08-19 10:38 ` redi at gcc dot gnu.org
@ 2021-08-19 13:57 ` cvs-commit at gcc dot gnu.org
2021-08-19 14:10 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-19 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:85a709595005b5df4b2ee9d81717a5df19c0023f
commit r12-3025-g85a709595005b5df4b2ee9d81717a5df19c0023f
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Aug 19 13:05:54 2021 +0100
libstdc++: Don't check always-true condition [PR101965]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/101965
* include/std/charconv (__to_chars_i): Remove redundant check.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/101965] check in charconv is vacuously true
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
` (2 preceding siblings ...)
2021-08-19 13:57 ` cvs-commit at gcc dot gnu.org
@ 2021-08-19 14:10 ` redi at gcc dot gnu.org
2021-08-24 16:01 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-19 14:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
Severity|normal |trivial
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk, but I plan to backport it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/101965] check in charconv is vacuously true
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
` (3 preceding siblings ...)
2021-08-19 14:10 ` redi at gcc dot gnu.org
@ 2021-08-24 16:01 ` cvs-commit at gcc dot gnu.org
2021-11-26 16:35 ` cvs-commit at gcc dot gnu.org
2021-11-26 17:30 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-24 16:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:8334ee1922104b5379efe94a19e17bc630cae9d5
commit r11-8922-g8334ee1922104b5379efe94a19e17bc630cae9d5
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Aug 19 13:05:54 2021 +0100
libstdc++: Don't check always-true condition [PR101965]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/101965
* include/std/charconv (__to_chars_i): Remove redundant check.
(cherry picked from commit 85a709595005b5df4b2ee9d81717a5df19c0023f)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/101965] check in charconv is vacuously true
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
` (4 preceding siblings ...)
2021-08-24 16:01 ` cvs-commit at gcc dot gnu.org
@ 2021-11-26 16:35 ` cvs-commit at gcc dot gnu.org
2021-11-26 17:30 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-26 16:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:30033d9bb9d5e5303fadf448999f4f27e2693ed6
commit r10-10309-g30033d9bb9d5e5303fadf448999f4f27e2693ed6
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Aug 19 13:05:54 2021 +0100
libstdc++: Don't check always-true condition [PR101965]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/101965
* include/std/charconv (__to_chars_i): Remove redundant check.
(cherry picked from commit 85a709595005b5df4b2ee9d81717a5df19c0023f)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/101965] check in charconv is vacuously true
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
` (5 preceding siblings ...)
2021-11-26 16:35 ` cvs-commit at gcc dot gnu.org
@ 2021-11-26 17:30 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-26 17:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101965
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 11.3 and 10.4
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-11-26 17:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 18:19 [Bug libstdc++/101965] New: check in charconv is vacuously true barry.revzin at gmail dot com
2021-08-19 10:37 ` [Bug libstdc++/101965] " redi at gcc dot gnu.org
2021-08-19 10:38 ` redi at gcc dot gnu.org
2021-08-19 13:57 ` cvs-commit at gcc dot gnu.org
2021-08-19 14:10 ` redi at gcc dot gnu.org
2021-08-24 16:01 ` cvs-commit at gcc dot gnu.org
2021-11-26 16:35 ` cvs-commit at gcc dot gnu.org
2021-11-26 17:30 ` redi at gcc dot gnu.org
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).