public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result @ 2022-08-24 13:26 jakob at schmutz dot co.uk 2022-08-24 13:28 ` [Bug c++/106734] " jakob at schmutz dot co.uk ` (6 more replies) 0 siblings, 7 replies; 8+ messages in thread From: jakob at schmutz dot co.uk @ 2022-08-24 13:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 Bug ID: 106734 Summary: [requires] std::same_as in compound requirements doesn't produce expected result Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jakob at schmutz dot co.uk Target Milestone: --- On gcc version 12.2.0 (and 11.3.0) I would expect the following code ``` #include <iostream> struct Bar { }; int main() { Bar bar; constexpr bool same = requires { { bar } -> std::same_as<Bar>; }; constexpr bool conv = requires { { bar } -> std::convertible_to<Bar>; }; if constexpr (std::same_as<decltype(bar), Bar>) { std::cout << "AS SAME" << std::endl; } if constexpr (std::is_same_v<decltype(bar), Bar>) { std::cout << "IS SAME" << std::endl; } if constexpr (same) { std::cout << "REQUIRES SAME" << std::endl; } if constexpr (conv) { std::cout << "CONVERTIBLE" << std::endl; } return 0; } ``` to return ``` AS SAME IS SAME REQUIRES SAME CONVERTIBLE ``` based on how how [compound requires](https://en.cppreference.com/w/cpp/language/requires) section reads but instead it returns ``` IS SAME REQUIRES SAME CONVERTIBLE ``` compiled with `g++ temp.cpp -std=c++20` compiling with `clang++ temp.cpp -std=c++20` produces the expected output ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/106734] [requires] std::same_as in compound requirements doesn't produce expected result 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk @ 2022-08-24 13:28 ` jakob at schmutz dot co.uk 2022-08-24 13:36 ` jakob at schmutz dot co.uk ` (5 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: jakob at schmutz dot co.uk @ 2022-08-24 13:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 --- Comment #1 from jakob at schmutz dot co.uk --- > but instead it returns > > ``` > IS SAME > REQUIRES SAME > CONVERTIBLE > ``` whoops this was supposed to be ``` AS SAME IS SAME CONVERTIBLE ``` ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/106734] [requires] std::same_as in compound requirements doesn't produce expected result 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk 2022-08-24 13:28 ` [Bug c++/106734] " jakob at schmutz dot co.uk @ 2022-08-24 13:36 ` jakob at schmutz dot co.uk 2022-08-24 14:00 ` redi at gcc dot gnu.org ` (4 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: jakob at schmutz dot co.uk @ 2022-08-24 13:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 --- Comment #2 from jakob at schmutz dot co.uk --- Created attachment 53503 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53503&action=edit preprocessed file ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/106734] [requires] std::same_as in compound requirements doesn't produce expected result 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk 2022-08-24 13:28 ` [Bug c++/106734] " jakob at schmutz dot co.uk 2022-08-24 13:36 ` jakob at schmutz dot co.uk @ 2022-08-24 14:00 ` redi at gcc dot gnu.org 2022-08-24 14:17 ` jakob at schmutz dot co.uk ` (3 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: redi at gcc dot gnu.org @ 2022-08-24 14:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to jakob from comment #0) > Bar bar; > constexpr bool same = requires > { > { bar } -> std::same_as<Bar>; This is false. The type of decltype((bar)) is Bar&. So I think GCC is correct. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/106734] [requires] std::same_as in compound requirements doesn't produce expected result 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk ` (2 preceding siblings ...) 2022-08-24 14:00 ` redi at gcc dot gnu.org @ 2022-08-24 14:17 ` jakob at schmutz dot co.uk 2022-08-24 14:21 ` jakob at schmutz dot co.uk ` (2 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: jakob at schmutz dot co.uk @ 2022-08-24 14:17 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 --- Comment #4 from jakob at schmutz dot co.uk --- (In reply to Jonathan Wakely from comment #3) > (In reply to jakob from comment #0) > > Bar bar; > > constexpr bool same = requires > > { > > { bar } -> std::same_as<Bar>; > > This is false. The type of decltype((bar)) is Bar&. > > So I think GCC is correct. Right but then why is `std::same_as<decltype(bar), Bar>` true? Shouldn't that also be false then? ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/106734] [requires] std::same_as in compound requirements doesn't produce expected result 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk ` (3 preceding siblings ...) 2022-08-24 14:17 ` jakob at schmutz dot co.uk @ 2022-08-24 14:21 ` jakob at schmutz dot co.uk 2022-08-24 14:25 ` jakob at schmutz dot co.uk 2022-08-24 14:27 ` redi at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: jakob at schmutz dot co.uk @ 2022-08-24 14:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 --- Comment #5 from jakob at schmutz dot co.uk --- oh I see `std::same_as<decltype((bar)), Bar>` is false ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/106734] [requires] std::same_as in compound requirements doesn't produce expected result 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk ` (4 preceding siblings ...) 2022-08-24 14:21 ` jakob at schmutz dot co.uk @ 2022-08-24 14:25 ` jakob at schmutz dot co.uk 2022-08-24 14:27 ` redi at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: jakob at schmutz dot co.uk @ 2022-08-24 14:25 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 jakob at schmutz dot co.uk changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #6 from jakob at schmutz dot co.uk --- Will close then as I agree that GCC is correct (I just found it a little confusing) ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/106734] [requires] std::same_as in compound requirements doesn't produce expected result 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk ` (5 preceding siblings ...) 2022-08-24 14:25 ` jakob at schmutz dot co.uk @ 2022-08-24 14:27 ` redi at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: redi at gcc dot gnu.org @ 2022-08-24 14:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734 --- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- decltype(bar) and decltype((bar)) are not the same type. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-08-24 14:27 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk 2022-08-24 13:28 ` [Bug c++/106734] " jakob at schmutz dot co.uk 2022-08-24 13:36 ` jakob at schmutz dot co.uk 2022-08-24 14:00 ` redi at gcc dot gnu.org 2022-08-24 14:17 ` jakob at schmutz dot co.uk 2022-08-24 14:21 ` jakob at schmutz dot co.uk 2022-08-24 14:25 ` jakob at schmutz dot co.uk 2022-08-24 14:27 ` 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).