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

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