public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy
@ 2021-05-26 14:49 hewillk at gmail dot com
2021-05-26 14:59 ` [Bug libstdc++/100770] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: hewillk at gmail dot com @ 2021-05-26 14:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100770
Bug ID: 100770
Summary: Incorrect if constexpr statement in
ranges::unique_copy
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
In ranges::unique_copy in ranges_algo.h#L1435:
else if constexpr (input_iterator<_Out>
&& same_as<iter_value_t<_Iter>, iter_value_t<_Out>>)
Since there is no short circuit in if constexpr statement, this will
incorrectly abort compilation when iter_value_t<_Out> is ill-formed.
(thanks T.C. for pointing that out).
#include <algorithm>
#include <iostream>
#include <sstream>
int main() {
std::istringstream str("42 42 42");
std::ranges::unique_copy(
std::istream_iterator<int>(str),
std::istream_iterator<int>(),
std::ostream_iterator<int>(std::cout, " "));
}
https://godbolt.org/z/PM58b3KrE
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/100770] Incorrect if constexpr statement in ranges::unique_copy
2021-05-26 14:49 [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy hewillk at gmail dot com
@ 2021-05-26 14:59 ` redi at gcc dot gnu.org
2021-05-26 15:25 ` ppalka at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-26 14:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100770
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Last reconfirmed| |2021-05-26
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/100770] Incorrect if constexpr statement in ranges::unique_copy
2021-05-26 14:49 [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy hewillk at gmail dot com
2021-05-26 14:59 ` [Bug libstdc++/100770] " redi at gcc dot gnu.org
@ 2021-05-26 15:25 ` ppalka at gcc dot gnu.org
2021-06-03 16:36 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-26 15:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100770
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
CC| |ppalka at gcc dot gnu.org
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
We should use a requires expression here instead.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/100770] Incorrect if constexpr statement in ranges::unique_copy
2021-05-26 14:49 [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy hewillk at gmail dot com
2021-05-26 14:59 ` [Bug libstdc++/100770] " redi at gcc dot gnu.org
2021-05-26 15:25 ` ppalka at gcc dot gnu.org
@ 2021-06-03 16:36 ` ppalka at gcc dot gnu.org
2021-06-10 21:11 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-03 16:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100770
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far by r12-1195:
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu, 3 Jun 2021 12:30:29 -0400
libstdc++: Avoid hard error in ranges::unique_copy [PR100770]
Here, in the constexpr if condition within ranges::unique_copy, when
input_iterator<_Out> isn't satisfied we must avoid substituting into
iter_value_t<_Out> because the latter isn't necessarily well-formed
then. To that end, this patch factors out the condition into a concept
and uses it throughout.
This patch also makes the definition of our testsuite
output_iterator_wrapper more minimal by setting its value_type, pointer
and reference member types to void. This means our existing tests for
unique_copy already exercise the fix for this bug, so we don't need
to add another test. The only other fallout of this testsuite iterator
change appears in std/ranges/range.cc, where the use of range_value_t
on a test_output_range is now ill-formed.
libstdc++-v3/ChangeLog:
* include/bits/ranges_algo.h (__detail::__can_reread_output):
Factor out this concept from ...
(__unique_copy_fn::operator()): ... here. Use the concept
throughout.
* testsuite/std/ranges/range.cc: Remove now ill-formed use
of range_value_t on an output_range.
* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
Define value_type, pointer and reference member types to void.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/100770] Incorrect if constexpr statement in ranges::unique_copy
2021-05-26 14:49 [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy hewillk at gmail dot com
` (2 preceding siblings ...)
2021-06-03 16:36 ` ppalka at gcc dot gnu.org
@ 2021-06-10 21:11 ` cvs-commit at gcc dot gnu.org
2021-06-10 21:22 ` cvs-commit at gcc dot gnu.org
2021-06-10 21:23 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-10 21:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100770
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:a35c5a5fc3eb610b77833855048163486c2fdb49
commit r11-8546-ga35c5a5fc3eb610b77833855048163486c2fdb49
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Jun 3 12:30:29 2021 -0400
libstdc++: Avoid hard error in ranges::unique_copy [PR100770]
Here, in the constexpr if condition within ranges::unique_copy, when
input_iterator<_Out> isn't satisfied we must avoid substituting into
iter_value_t<_Out> because the latter isn't necessarily well-formed
then. To that end, this patch factors out the condition into a concept
and uses it throughout.
This patch also makes the definition of our testsuite
output_iterator_wrapper more minimal by setting its value_type, pointer
and reference member types to void. This means our existing tests for
unique_copy already exercise the fix for this bug, so we don't need
to add another test. The only other fallout of this testsuite iterator
change appears in std/ranges/range.cc, where the use of range_value_t
on a test_output_range is now ill-formed.
PR libstdc++/100770
libstdc++-v3/ChangeLog:
* include/bits/ranges_algo.h (__detail::__can_reread_output):
Factor out this concept from ...
(__unique_copy_fn::operator()): ... here. Use the concept
throughout.
* testsuite/std/ranges/range.cc: Remove now ill-formed use
of range_value_t on an output_range.
* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
Define value_type, pointer and reference member types to void.
(cherry picked from commit 0614bbbe59c6953e088cffa39dfe63d86fc1fa96)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/100770] Incorrect if constexpr statement in ranges::unique_copy
2021-05-26 14:49 [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy hewillk at gmail dot com
` (3 preceding siblings ...)
2021-06-10 21:11 ` cvs-commit at gcc dot gnu.org
@ 2021-06-10 21:22 ` cvs-commit at gcc dot gnu.org
2021-06-10 21:23 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-10 21:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100770
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:bee80d74f7ebc8e1ada913aa059dedc0976f28c0
commit r10-9908-gbee80d74f7ebc8e1ada913aa059dedc0976f28c0
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Jun 3 12:30:29 2021 -0400
libstdc++: Avoid hard error in ranges::unique_copy [PR100770]
Here, in the constexpr if condition within ranges::unique_copy, when
input_iterator<_Out> isn't satisfied we must avoid substituting into
iter_value_t<_Out> because the latter isn't necessarily well-formed
then. To that end, this patch factors out the condition into a concept
and uses it throughout.
This patch also makes the definition of our testsuite
output_iterator_wrapper more minimal by setting its value_type, pointer
and reference member types to void. This means our existing tests for
unique_copy already exercise the fix for this bug, so we don't need
to add another test. The only other fallout of this testsuite iterator
change appears in std/ranges/range.cc, where the use of range_value_t
on a test_output_range is now ill-formed.
PR libstdc++/100770
libstdc++-v3/ChangeLog:
* include/bits/ranges_algo.h (__detail::__can_reread_output):
Factor out this concept from ...
(__unique_copy_fn::operator()): ... here. Use the concept
throughout.
* testsuite/std/ranges/range.cc: Remove now ill-formed use
of range_value_t on an output_range.
* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
Define value_type, pointer and reference member types to void.
(cherry picked from commit 0614bbbe59c6953e088cffa39dfe63d86fc1fa96)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/100770] Incorrect if constexpr statement in ranges::unique_copy
2021-05-26 14:49 [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy hewillk at gmail dot com
` (4 preceding siblings ...)
2021-06-10 21:22 ` cvs-commit at gcc dot gnu.org
@ 2021-06-10 21:23 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-10 21:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100770
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 10.4/11.2/12
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-06-10 21:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 14:49 [Bug libstdc++/100770] New: Incorrect if constexpr statement in ranges::unique_copy hewillk at gmail dot com
2021-05-26 14:59 ` [Bug libstdc++/100770] " redi at gcc dot gnu.org
2021-05-26 15:25 ` ppalka at gcc dot gnu.org
2021-06-03 16:36 ` ppalka at gcc dot gnu.org
2021-06-10 21:11 ` cvs-commit at gcc dot gnu.org
2021-06-10 21:22 ` cvs-commit at gcc dot gnu.org
2021-06-10 21:23 ` ppalka 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).