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

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).