public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument. @ 2023-04-16 6:42 lisp2d at rambler dot ru 2023-04-16 6:51 ` [Bug c++/109529] " pinskia at gcc dot gnu.org ` (6 more replies) 0 siblings, 7 replies; 8+ messages in thread From: lisp2d at rambler dot ru @ 2023-04-16 6:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 Bug ID: 109529 Summary: the r-value volatile object is not accepted by the l-value volatile constant argument. Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lisp2d at rambler dot ru Target Milestone: --- void funy(int const &){} void fun(int volatile const &){} int main(){ int y ; funy(y); // good funy(static_cast<int && >(y)); // good funy(static_cast<int const && >(y)); // good int volatile x ; fun(x); // good fun(static_cast<int volatile && >(x)); // error fun(static_cast<int volatile const && >(x)); // error } ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/109529] the r-value volatile object is not accepted by the l-value volatile constant argument. 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru @ 2023-04-16 6:51 ` pinskia at gcc dot gnu.org 2023-04-16 6:58 ` pinskia at gcc dot gnu.org ` (5 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-04-16 6:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- only const references can be bound to temporaries. const volatile references cannot be bound to a temporary. That is even this is invalid code: ``` int main(){ const volatile int & a = 1; } ``` ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/109529] the r-value volatile object is not accepted by the l-value volatile constant argument. 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru 2023-04-16 6:51 ` [Bug c++/109529] " pinskia at gcc dot gnu.org @ 2023-04-16 6:58 ` pinskia at gcc dot gnu.org 2023-04-16 7:49 ` lisp2d at rambler dot ru ` (4 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-04-16 6:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Since `static_cast<int volatile && >(x)` is considered rvalue and `int volatile const &` needs to be bound, it will not be bound to a temporary (rvalue) which is produced by the rvalue reference. In the non-volatile case, well it is a const reference which can be bound to a temporary value (rvalue) and that temp in this case will end its lifetime after the end of the statement (after the ;). ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/109529] the r-value volatile object is not accepted by the l-value volatile constant argument. 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru 2023-04-16 6:51 ` [Bug c++/109529] " pinskia at gcc dot gnu.org 2023-04-16 6:58 ` pinskia at gcc dot gnu.org @ 2023-04-16 7:49 ` lisp2d at rambler dot ru 2023-04-16 7:58 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: lisp2d at rambler dot ru @ 2023-04-16 7:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 --- Comment #3 from Lisp2D <lisp2d at rambler dot ru> --- (In reply to Andrew Pinski from comment #2) > Since `static_cast<int volatile && >(x)` is considered rvalue and `int I can't find a reason anywhere in the standard why the volatile property prevents conversion from `&&` to `const &`. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/109529] the r-value volatile object is not accepted by the l-value volatile constant argument. 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru ` (2 preceding siblings ...) 2023-04-16 7:49 ` lisp2d at rambler dot ru @ 2023-04-16 7:58 ` pinskia at gcc dot gnu.org 2023-04-16 8:26 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-04-16 7:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- https://stackoverflow.com/questions/40193008/why-a-const-volatile-reference-cannot-be-bound-to-an-rvalue-reference ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/109529] the r-value volatile object is not accepted by the l-value volatile constant argument. 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru ` (3 preceding siblings ...) 2023-04-16 7:58 ` pinskia at gcc dot gnu.org @ 2023-04-16 8:26 ` pinskia at gcc dot gnu.org 2023-04-16 9:08 ` lisp2d at rambler dot ru 2023-04-16 10:34 ` lisp2d at rambler dot ru 6 siblings, 0 replies; 8+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-04-16 8:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Basically [dcl.init.ref]/5 . ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/109529] the r-value volatile object is not accepted by the l-value volatile constant argument. 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru ` (4 preceding siblings ...) 2023-04-16 8:26 ` pinskia at gcc dot gnu.org @ 2023-04-16 9:08 ` lisp2d at rambler dot ru 2023-04-16 10:34 ` lisp2d at rambler dot ru 6 siblings, 0 replies; 8+ messages in thread From: lisp2d at rambler dot ru @ 2023-04-16 9:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 --- Comment #6 from Lisp2D <lisp2d at rambler dot ru> --- (In reply to Andrew Pinski from comment #4) > https://stackoverflow.com/questions/40193008/why-a-const-volatile-reference- stackoverflow offers to link an rvalue reference to a variable for this. But I think this is historical stupidity. int volatile && rx = static_cast < int volatile && > ( x ) ; int volatile const & lx = rx ; fun(lx); ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/109529] the r-value volatile object is not accepted by the l-value volatile constant argument. 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru ` (5 preceding siblings ...) 2023-04-16 9:08 ` lisp2d at rambler dot ru @ 2023-04-16 10:34 ` lisp2d at rambler dot ru 6 siblings, 0 replies; 8+ messages in thread From: lisp2d at rambler dot ru @ 2023-04-16 10:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109529 --- Comment #7 from Lisp2D <lisp2d at rambler dot ru> --- .. or int volatile && rx = static_cast < int volatile && > ( x ) ; fun(rx); ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-04-16 10:34 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-04-16 6:42 [Bug c++/109529] New: the r-value volatile object is not accepted by the l-value volatile constant argument lisp2d at rambler dot ru 2023-04-16 6:51 ` [Bug c++/109529] " pinskia at gcc dot gnu.org 2023-04-16 6:58 ` pinskia at gcc dot gnu.org 2023-04-16 7:49 ` lisp2d at rambler dot ru 2023-04-16 7:58 ` pinskia at gcc dot gnu.org 2023-04-16 8:26 ` pinskia at gcc dot gnu.org 2023-04-16 9:08 ` lisp2d at rambler dot ru 2023-04-16 10:34 ` lisp2d at rambler dot ru
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).