public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/113629] New: 'deducing this' does not work with conversion operators @ 2024-01-27 17:01 hewillk at gmail dot com 2024-01-27 17:02 ` [Bug c++/113629] " hewillk at gmail dot com ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: hewillk at gmail dot com @ 2024-01-27 17:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113629 Bug ID: 113629 Summary: 'deducing this' does not work with conversion operators Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- It seems that GCC's deducing this implementation has some issues with derived classes that inherit from a base class that has conversion operators: struct Base { operator int(this auto&&) { return 42; } }; struct Derived : Base {}; int main() { Derived derived; return static_cast<int>(derived); } GCC rejects the above code with: <source>:11:10: error: invalid 'static_cast' from type 'Derived' to type 'int' 11 | return static_cast<int>(derived); | ^~~~~~~~~~~~~~~~~~~~~~~~~ which seems wrong. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113629] 'deducing this' does not work with conversion operators 2024-01-27 17:01 [Bug c++/113629] New: 'deducing this' does not work with conversion operators hewillk at gmail dot com @ 2024-01-27 17:02 ` hewillk at gmail dot com 2024-01-27 17:24 ` hewillk at gmail dot com ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: hewillk at gmail dot com @ 2024-01-27 17:02 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113629 --- Comment #1 from 康桓瑋 <hewillk at gmail dot com> --- test: https://godbolt.org/z/jdz3ejohv ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113629] 'deducing this' does not work with conversion operators 2024-01-27 17:01 [Bug c++/113629] New: 'deducing this' does not work with conversion operators hewillk at gmail dot com 2024-01-27 17:02 ` [Bug c++/113629] " hewillk at gmail dot com @ 2024-01-27 17:24 ` hewillk at gmail dot com 2024-03-06 9:49 ` cvs-commit at gcc dot gnu.org 2024-03-06 9:50 ` nshead at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: hewillk at gmail dot com @ 2024-01-27 17:24 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113629 --- Comment #2 from 康桓瑋 <hewillk at gmail dot com> --- more reduced: struct Base { operator int(this auto&&) { return 42; } }; int main() { Base b; // return static_cast<int>(Base{}); // ok return static_cast<int>(b); // error } https://godbolt.org/z/qGrbf4rj7 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113629] 'deducing this' does not work with conversion operators 2024-01-27 17:01 [Bug c++/113629] New: 'deducing this' does not work with conversion operators hewillk at gmail dot com 2024-01-27 17:02 ` [Bug c++/113629] " hewillk at gmail dot com 2024-01-27 17:24 ` hewillk at gmail dot com @ 2024-03-06 9:49 ` cvs-commit at gcc dot gnu.org 2024-03-06 9:50 ` nshead at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2024-03-06 9:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113629 --- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>: https://gcc.gnu.org/g:49d83e963aa453600088380aebd507e172eb80ad commit r14-9332-g49d83e963aa453600088380aebd507e172eb80ad Author: Nathaniel Shead <nathanieloshead@gmail.com> Date: Wed Mar 6 00:43:22 2024 +1100 c++: Fix template deduction for conversion operators with xobj parameters [PR113629] Unification for conversion operators (DEDUCE_CONV) doesn't perform transformations like handling forwarding references. This is correct in general, but not for xobj parameters, which should be handled "normally" for the purposes of deduction: [temp.deduct.conv] only applies to the return type of the conversion function. PR c++/113629 gcc/cp/ChangeLog: * pt.cc (type_unification_real): Only use DEDUCE_CONV for the return type of a conversion function. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-conv-op.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/113629] 'deducing this' does not work with conversion operators 2024-01-27 17:01 [Bug c++/113629] New: 'deducing this' does not work with conversion operators hewillk at gmail dot com ` (2 preceding siblings ...) 2024-03-06 9:49 ` cvs-commit at gcc dot gnu.org @ 2024-03-06 9:50 ` nshead at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: nshead at gcc dot gnu.org @ 2024-03-06 9:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113629 Nathaniel Shead <nshead at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |14.0 Assignee|unassigned at gcc dot gnu.org |nshead at gcc dot gnu.org Resolution|--- |FIXED CC| |nshead at gcc dot gnu.org Status|UNCONFIRMED |RESOLVED --- Comment #4 from Nathaniel Shead <nshead at gcc dot gnu.org> --- Fixed. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-06 9:50 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-01-27 17:01 [Bug c++/113629] New: 'deducing this' does not work with conversion operators hewillk at gmail dot com 2024-01-27 17:02 ` [Bug c++/113629] " hewillk at gmail dot com 2024-01-27 17:24 ` hewillk at gmail dot com 2024-03-06 9:49 ` cvs-commit at gcc dot gnu.org 2024-03-06 9:50 ` nshead 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).