public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105720] New: std::views::split_view wrong behaviour in case of partial match
@ 2022-05-24 15:29 andij.cr at gmail dot com
2022-05-24 16:43 ` [Bug libstdc++/105720] " ppalka at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: andij.cr at gmail dot com @ 2022-05-24 15:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105720
Bug ID: 105720
Summary: std::views::split_view wrong behaviour in case of
partial match
Product: gcc
Version: 10.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: andij.cr at gmail dot com
Target Milestone: ---
compiled with
g++-10 -std=c++20 split_view_wrong.cpp -lfmt
godbolt link https://gcc.godbolt.org/z/47TxWovd4
fmtlib used for exposition only
#include <fmt/printf.h>
#include <fmt/ranges.h>
#include <ranges>
#include <string_view>
auto words_no_bug = std::string_view{"Hello-_-C++-_-20-_-!-_-"};
auto words_bug = std::string_view{"Hello--_-C++-_-20-_-!-_-"};
auto delim = std::string_view{"-_-"};
// needed because split_view is lazy in gcc 10.3
auto range_to_str = [](auto &&r) {
return fmt::format("{}", fmt::join(r, ""));
};
int main() {
fmt::print("no bug: '{}' tokens: {}\n", words_no_bug,
words_no_bug | std::views::split(delim) |
std::views::transform(range_to_str));
fmt::print("bug: '{}' tokens: {}\n", words_bug,
words_bug | std::views::split(delim) |
std::views::transform(range_to_str));
}
this code applies split to tokenize a text
compiled with gcc-10.3 it wrongly produces
no bug: 'Hello-_-C++-_-20-_-!-_-' tokens: ["Hello", "C++", "20", "!"]
bug: 'Hello--_-C++-_-20-_-!-_-' tokens: ["Hello-", "20", "!"]
while compiled with gcc-11.3 is correctly produces
no bug: 'Hello-_-C++-_-20-_-!-_-' tokens: ["Hello", "C++", "20", "!"]
bug: 'Hello--_-C++-_-20-_-!-_-' tokens: ["Hello-", "C++", "20", "!"]
notice how the substring "--_-C++" instead of being split in ["-", "C++"]
is split as ["-"], skipping the "C++" token.
it's fixed from gcc-11, but i couldn't find a mention in the release notes
about it
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libstdc++/105720] std::views::split_view wrong behaviour in case of partial match
2022-05-24 15:29 [Bug libstdc++/105720] New: std::views::split_view wrong behaviour in case of partial match andij.cr at gmail dot com
@ 2022-05-24 16:43 ` ppalka at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-24 16:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105720
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
CC| |ppalka at gcc dot gnu.org
Target Milestone|--- |10.4
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I think you're running into the LWG issue https://wg21.link/lwg3505 which has
been adopted as a defect report against C++20, and implemented for libstdc++
10.4 (not yet released) and 11+ (as you've noticed). It's been backported to
the 10 release branch as r10-9740-g4c17b2bbbc1bef on April 20, 2021, so any
snapshot of libstdc++ 10 after that date should behave correctly.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-24 16:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 15:29 [Bug libstdc++/105720] New: std::views::split_view wrong behaviour in case of partial match andij.cr at gmail dot com
2022-05-24 16:43 ` [Bug libstdc++/105720] " 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).