public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/106376] New: The implementation of std::pointer_traits seems wrong
@ 2022-07-21 3:56 hewillk at gmail dot com
2022-07-21 4:09 ` [Bug libstdc++/106376] " hewillk at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: hewillk at gmail dot com @ 2022-07-21 3:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106376
Bug ID: 106376
Summary: The implementation of std::pointer_traits seems wrong
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
[pointer.traits.types]:
using element_type = see below;
Type: Ptr::element_type if the qualified-id Ptr::element_type is valid
and denotes a type ([temp.deduct]); otherwise, T if Ptr is a class template
instantiation of the form SomePointer<T, Args>, where Args is zero or more type
arguments; otherwise, the specialization is *ill-formed*.
So for the following, the instantiation of pointer_traits will be ill-formed,
and static_assert will cause a hard error, just like libc++ and MSVC-STL do.
libstdc++ specifies element_type as a meaningless type, so the static_assert
still passes.
Although the behavior of libstdc++ is incorrect, but I am not feel good about
this static_assert hard error..
#include <iterator>
struct I {
using iterator_category = std::contiguous_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = int;
value_type& operator*() const;
I& operator++();
I operator++(int);
I& operator--();
I operator--(int);
I& operator+=(difference_type);
I& operator-=(difference_type);
value_type* operator->() const;
value_type& operator[](difference_type) const;
friend I operator+(I, difference_type);
friend I operator+(difference_type, I);
friend I operator-(I, difference_type);
friend difference_type operator-(I, I);
auto operator<=>(const I&) const = default;
};
static_assert(std::contiguous_iterator<I>);
https://godbolt.org/z/sx763oMn6
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/106376] The implementation of std::pointer_traits seems wrong
2022-07-21 3:56 [Bug libstdc++/106376] New: The implementation of std::pointer_traits seems wrong hewillk at gmail dot com
@ 2022-07-21 4:09 ` hewillk at gmail dot com
2022-07-21 9:06 ` [Bug libstdc++/106376] [LWG3545] " redi at gcc dot gnu.org
2023-04-26 21:47 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: hewillk at gmail dot com @ 2022-07-21 4:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106376
--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
oops, this is basically https://cplusplus.github.io/LWG/issue3545, I am waiting
for your paper.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/106376] [LWG3545] The implementation of std::pointer_traits seems wrong
2022-07-21 3:56 [Bug libstdc++/106376] New: The implementation of std::pointer_traits seems wrong hewillk at gmail dot com
2022-07-21 4:09 ` [Bug libstdc++/106376] " hewillk at gmail dot com
@ 2022-07-21 9:06 ` redi at gcc dot gnu.org
2023-04-26 21:47 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-21 9:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106376
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |SUSPENDED
Ever confirmed|0 |1
Last reconfirmed| |2022-07-21
Summary|The implementation of |[LWG3545] The
|std::pointer_traits seems |implementation of
|wrong |std::pointer_traits seems
| |wrong
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to 康桓瑋 from comment #0)
> libstdc++ specifies element_type as a meaningless type, so the static_assert
> still passes.
>
> Although the behavior of libstdc++ is incorrect, but I am not feel good
> about this static_assert hard error..
Right, it's completely unusable, see PR 96416.
Libstdc++ already implements my proposed solution, the standard just hasn't
caught up yet ;-)
Suspending until 3545 is resolved, but I expect to close this at some future
date, as there's nothing for libstdc++ to do here.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/106376] [LWG3545] The implementation of std::pointer_traits seems wrong
2022-07-21 3:56 [Bug libstdc++/106376] New: The implementation of std::pointer_traits seems wrong hewillk at gmail dot com
2022-07-21 4:09 ` [Bug libstdc++/106376] " hewillk at gmail dot com
2022-07-21 9:06 ` [Bug libstdc++/106376] [LWG3545] " redi at gcc dot gnu.org
@ 2023-04-26 21:47 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-26 21:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106376
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |WORKSFORME
Status|SUSPENDED |RESOLVED
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Closing ,as libstdc++ matches the C++23 working paper.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-26 21:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 3:56 [Bug libstdc++/106376] New: The implementation of std::pointer_traits seems wrong hewillk at gmail dot com
2022-07-21 4:09 ` [Bug libstdc++/106376] " hewillk at gmail dot com
2022-07-21 9:06 ` [Bug libstdc++/106376] [LWG3545] " redi at gcc dot gnu.org
2023-04-26 21:47 ` 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).