public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/103951] New: [C++2b] string_view range constructor, "exception specification ... depends on itself"
@ 2022-01-09 10:23 iamsupermouse at mail dot ru
2022-01-09 10:58 ` [Bug libstdc++/103951] " hewillk at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: iamsupermouse at mail dot ru @ 2022-01-09 10:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103951
Bug ID: 103951
Summary: [C++2b] string_view range constructor, "exception
specification ... depends on itself"
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: iamsupermouse at mail dot ru
Target Milestone: ---
Following code compiles with -std=c++20 and earlier, but fails with -std=c++2b,
in both GCC and Clang with libstdc++, with similar errors.
I've tested both on GCC 11.2 and on trunk 12.0.0 20220109 at gcc.godbolt.org.
#include <string_view>
struct Iter
{
Iter() {}
Iter(std::string_view) {} // Adding `explicit` fixes the error
Iter begin() const
{
return *this;
}
};
It's supposed to be used as `for (auto x : Iter(...))`, exactly like
`fs::directory_iterator`, but I've removed `end()` and overloaded operators for
brevity.
The error message boils down to `return *this` considering the `string_view`
constructor, which checks `Iter` against `contiguous_range`, which circularly
checks `begin()`.
I'm not sure if the code is legal or not, but the error is very unintuitive, so
I decided to report it. I would expect this to be a soft SFINAE failure.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/103951] [C++2b] string_view range constructor, "exception specification ... depends on itself"
2022-01-09 10:23 [Bug libstdc++/103951] New: [C++2b] string_view range constructor, "exception specification ... depends on itself" iamsupermouse at mail dot ru
@ 2022-01-09 10:58 ` hewillk at gmail dot com
2022-01-09 15:54 ` hewillk at gmail dot com
2022-01-10 9:39 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: hewillk at gmail dot com @ 2022-01-09 10:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103951
康桓瑋 <hewillk at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hewillk at gmail dot com
--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
Reduced a bit:
#include <ranges>
struct string_view {
string_view(std::ranges::range auto&&);
};
struct Iter {
Iter(string_view);
Iter begin() const { return *this; }
};
https://godbolt.org/z/n93o9f9nK
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/103951] [C++2b] string_view range constructor, "exception specification ... depends on itself"
2022-01-09 10:23 [Bug libstdc++/103951] New: [C++2b] string_view range constructor, "exception specification ... depends on itself" iamsupermouse at mail dot ru
2022-01-09 10:58 ` [Bug libstdc++/103951] " hewillk at gmail dot com
@ 2022-01-09 15:54 ` hewillk at gmail dot com
2022-01-10 9:39 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: hewillk at gmail dot com @ 2022-01-09 15:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103951
--- Comment #2 from 康桓瑋 <hewillk at gmail dot com> ---
Here is the reduced version without the header:
template<class T>
T&& declval() noexcept;
struct true_type {
static constexpr bool value = true;
};
template<typename _From, typename _To>
class is_convertible {
template<typename _To1>
static void __test_aux(_To1) noexcept;
template<typename _From1, typename _To1,
typename = decltype(__test_aux<_To1>(declval<_From1>()))>
static true_type __test(int);
public:
static constexpr bool value = decltype(__test<_From, _To>(0))::value;
};
template<typename _Tp>
void __decay_copy(_Tp) noexcept(is_convertible<_Tp, _Tp>::value);
template<class _Tp>
concept range = requires(_Tp& __t) {
__decay_copy(__t.begin());
};
struct string_view {
template<range R>
string_view(R&&);
};
struct Iter {
Iter(string_view);
Iter begin() const { return *this; }
};
https://godbolt.org/z/nrcq84dno
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/103951] [C++2b] string_view range constructor, "exception specification ... depends on itself"
2022-01-09 10:23 [Bug libstdc++/103951] New: [C++2b] string_view range constructor, "exception specification ... depends on itself" iamsupermouse at mail dot ru
2022-01-09 10:58 ` [Bug libstdc++/103951] " hewillk at gmail dot com
2022-01-09 15:54 ` hewillk at gmail dot com
@ 2022-01-10 9:39 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-10 9:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103951
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This would be solved by
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2499r0.html but I
think the std::lib code is behaving exactly as the C++23 draft requires.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-10 9:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-09 10:23 [Bug libstdc++/103951] New: [C++2b] string_view range constructor, "exception specification ... depends on itself" iamsupermouse at mail dot ru
2022-01-09 10:58 ` [Bug libstdc++/103951] " hewillk at gmail dot com
2022-01-09 15:54 ` hewillk at gmail dot com
2022-01-10 9:39 ` 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).