public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible
@ 2024-08-17  7:50 hewillk at gmail dot com
  2024-08-19 10:47 ` [Bug libstdc++/116399] " redi at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: hewillk at gmail dot com @ 2024-08-17  7:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

            Bug ID: 116399
           Summary: C++26 text_encoding​::​aliases_view is not
                    default-constructible
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

text.encoding.aliases] indicates that text_encoding::aliases_view is an empty
struct, which suggests it is default-constructible.

However, the private custom constructors in the libstdc++ implementation make
it not so:

#include <text_encoding>

std::text_encoding::aliases_view av{};

https://godbolt.org/z/MahWfeW81

Not sure if this is LWG-worthy.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
@ 2024-08-19 10:47 ` redi at gcc dot gnu.org
  2024-08-19 12:43 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 10:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The working draft says:

  text_encoding::aliases_view models copyable, ranges::view,
ranges::random_access_range,
  and ranges::borrowed_range.

It specifically says copyable and not semiregular, which suggests to me that it
isn't required to model semiregular, so isn't required to be
default-initializable.

I think libstdc++ is correct, and the working draft should be clarified.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
  2024-08-19 10:47 ` [Bug libstdc++/116399] " redi at gcc dot gnu.org
@ 2024-08-19 12:43 ` redi at gcc dot gnu.org
  2024-08-19 12:48 ` corentinjabot at gmail dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 12:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |corentinjabot at gmail dot com

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
CC Corentin for confirmation of the intent.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
  2024-08-19 10:47 ` [Bug libstdc++/116399] " redi at gcc dot gnu.org
  2024-08-19 12:43 ` redi at gcc dot gnu.org
@ 2024-08-19 12:48 ` corentinjabot at gmail dot com
  2024-08-19 12:51 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: corentinjabot at gmail dot com @ 2024-08-19 12:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #3 from corentinjabot at gmail dot com ---
Yes, libstdc++ is correct.
Not sure what one would do with a default constructed alias aliases_view

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2024-08-19 12:48 ` corentinjabot at gmail dot com
@ 2024-08-19 12:51 ` redi at gcc dot gnu.org
  2024-08-19 13:16 ` hewillk at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 12:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thanks! I'll submit an LWG issue to add something saying there's an unspecified
constructor, or just say explicitly that it's not default constructible.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2024-08-19 12:51 ` redi at gcc dot gnu.org
@ 2024-08-19 13:16 ` hewillk at gmail dot com
  2024-08-19 13:56 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hewillk at gmail dot com @ 2024-08-19 13:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #5 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> Thanks! I'll submit an LWG issue to add something saying there's an
> unspecified constructor, or just say explicitly that it's not default
> constructible.

Not sure it's worth specifying whether aliases_view should or should not be
common_range, although currently, libstdc++ implementations are
non-common_range.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2024-08-19 13:16 ` hewillk at gmail dot com
@ 2024-08-19 13:56 ` redi at gcc dot gnu.org
  2024-08-19 13:58 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 13:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That's discussed in P1885.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (5 preceding siblings ...)
  2024-08-19 13:56 ` redi at gcc dot gnu.org
@ 2024-08-19 13:58 ` redi at gcc dot gnu.org
  2024-08-19 14:11 ` hewillk at gmail dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 13:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
"Note that this view is not common_range because it can be implemented more
efficiently
without that requirement, and, being copyable, it can be adapted into one."

and

"We found that aliases can be efficiently stored and looked up in a sorted list
of alias/mib pairs. Making a common_range of aliases_view would force an
implementation to find the end of the list of aliases for a particular
encoding, which is slightly efficient than what is possible, so this is not
proposed. Mostly, we found little use for it to be a common_range."

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (6 preceding siblings ...)
  2024-08-19 13:58 ` redi at gcc dot gnu.org
@ 2024-08-19 14:11 ` hewillk at gmail dot com
  2024-08-19 14:41 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hewillk at gmail dot com @ 2024-08-19 14:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #8 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Jonathan Wakely from comment #7)
> "Note that this view is not common_range because it can be implemented more
> efficiently
> without that requirement, and, being copyable, it can be adapted into one."
> 
> and
> 
> "We found that aliases can be efficiently stored and looked up in a sorted
> list of alias/mib pairs. Making a common_range of aliases_view would force
> an implementation to find the end of the list of aliases for a particular
> encoding, which is slightly efficient than what is possible, so this is not
> proposed. Mostly, we found little use for it to be a common_range."

If so, why not just explicitly specify that end() returns
std::default_sentinel? libstdc++'s _Sentinel is just an empty class, so there
is no need to introduce an additional class IMO.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (7 preceding siblings ...)
  2024-08-19 14:11 ` hewillk at gmail dot com
@ 2024-08-19 14:41 ` redi at gcc dot gnu.org
  2024-08-19 14:50 ` hewillk at gmail dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 14:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Currently aliases_view is allowed to be a common range, but not required to be.

If we specify that its sentinel type is std::default_sentinel, that would
require it to be a non-common range. Why would we want that?

If an implementation decides to use a different design for the aliases_view
which is more efficient with a common range, your suggestion would forbid them
from using that.

So I don't think we should require that. Whether libstdc++ should make that
change is a different matter.

I guess we could also defined the sentinel as an enum type, which might be a
little less expensive than a new class type. Or just use default_sentinel_t.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (8 preceding siblings ...)
  2024-08-19 14:41 ` redi at gcc dot gnu.org
@ 2024-08-19 14:50 ` hewillk at gmail dot com
  2024-08-19 15:01 ` redi at gcc dot gnu.org
  2024-08-19 15:02 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: hewillk at gmail dot com @ 2024-08-19 14:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #10 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Jonathan Wakely from comment #9)
> Currently aliases_view is allowed to be a common range, but not required to
> be.
> 
> If we specify that its sentinel type is std::default_sentinel, that would
> require it to be a non-common range. Why would we want that?
> 
> If an implementation decides to use a different design for the aliases_view
> which is more efficient with a common range, your suggestion would forbid
> them from using that.
> 
> So I don't think we should require that. Whether libstdc++ should make that
> change is a different matter.
> 
> I guess we could also defined the sentinel as an enum type, which might be a
> little less expensive than a new class type. Or just use default_sentinel_t.

But we should at least make it clear in the standard whether aliases_view is
common range is *unspecified*, right?
Currently, the return type of begin()/end() is *implementation defined*, which
seems confusing because the two types appear to be the same as we indicated for
iterators in the [container], and containers are always common ranges.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (9 preceding siblings ...)
  2024-08-19 14:50 ` hewillk at gmail dot com
@ 2024-08-19 15:01 ` redi at gcc dot gnu.org
  2024-08-19 15:02 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 15:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't agree. Containers do:

class X {
  using iterator = <implementation-defined>;
  iterator begin();
  iterator end();
};

So clearly the type is the same.

That's not how text_encoding::aliases_view is specified.

The standard doesn't say begin() and end() return the same type, and it doesn't
say aliases_view models common_range. So it's already unspecified.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug libstdc++/116399] C++26 text_encoding​::​aliases_view is not default-constructible
  2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
                   ` (10 preceding siblings ...)
  2024-08-19 15:01 ` redi at gcc dot gnu.org
@ 2024-08-19 15:02 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-19 15:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Implementation-defined means the implementation must define it (and document
it).

If the implementation says the types are different, then they're different, and
it's not a common range.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-08-19 15:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-17  7:50 [Bug libstdc++/116399] New: C++26 text_encoding​::​aliases_view is not default-constructible hewillk at gmail dot com
2024-08-19 10:47 ` [Bug libstdc++/116399] " redi at gcc dot gnu.org
2024-08-19 12:43 ` redi at gcc dot gnu.org
2024-08-19 12:48 ` corentinjabot at gmail dot com
2024-08-19 12:51 ` redi at gcc dot gnu.org
2024-08-19 13:16 ` hewillk at gmail dot com
2024-08-19 13:56 ` redi at gcc dot gnu.org
2024-08-19 13:58 ` redi at gcc dot gnu.org
2024-08-19 14:11 ` hewillk at gmail dot com
2024-08-19 14:41 ` redi at gcc dot gnu.org
2024-08-19 14:50 ` hewillk at gmail dot com
2024-08-19 15:01 ` redi at gcc dot gnu.org
2024-08-19 15:02 ` 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).