[Bug c++/80456] calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456 Dmitry Lebed changed: What|Removed |Added CC||lebed.dmitry at gmail dot com --- Comment #7 from Dmitry Lebed --- Just encountered the same issue independently https://stackoverflow.com/questions/64019728/are-there-any-caveats-in-c-with-constexpr-static-function-usage-in-volatile It's sad to see that it's already 3 years without fix. It's still valid for GCC trunk (according to godbolt) and at 10.2 (according to my local tests). Any hope in fixing this?
[Bug c++/80456] calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456 --- Comment #6 from Jakub Jelinek --- Oops, sorry Marek, seems you've said all that already, ignore my comment... :(.
[Bug c++/80456] calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org --- Comment #5 from Jakub Jelinek --- The test() call is represented as *(volatile struct A *) this, A::test () and the *this dereference in that case is what triggers the error (well, this itself). This is created by: 8827 /* In an expression of the form `a->f()' where `f' turns 8828 out to be a static member function, `a' is 8829 none-the-less evaluated. */ 8830 if (TREE_CODE (TREE_TYPE (fn)) != METHOD_TYPE 8831 && !is_dummy_object (instance) 8832 && TREE_SIDE_EFFECTS (instance)) 8833call = build2 (COMPOUND_EXPR, TREE_TYPE (call), 8834 instance, call); So shall we have some exception of *this if it is volatile and still ignore it?
[Bug c++/80456] calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456 --- Comment #4 from Jonathan Wakely --- Yeah, it doesn't need to evaluate 'this' in that declaration, it's calling a static member function.
[Bug c++/80456] calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456 --- Comment #3 from Richard Biener --- How is the C++ abstract machine defined in this case? I don't think you can constexpr evaluate any volatile load -- but of course in this case 'this' shouldn't be considered volatile in that sense?
[Bug c++/80456] calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456 --- Comment #2 from Marek Polacek --- With the volatile, cxx_eval_constant_expression sees *(volatile struct A *) this;, A::test(); and it's not able to evaluate 'this' in it. Without the volatile it only sees A::test() which it can evaluate. The COMPOUND_EXPR comes from build_new_method_call_1: 8827 /* In an expression of the form `a->f()' where `f' turns 8828 out to be a static member function, `a' is 8829 none-the-less evaluated. */ 8830 if (TREE_CODE (TREE_TYPE (fn)) != METHOD_TYPE 8831 && !is_dummy_object (instance) 8832 && TREE_SIDE_EFFECTS (instance)) 8833 call = build2 (COMPOUND_EXPR, TREE_TYPE (call), 8834instance, call);
[Bug c++/80456] calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-04-19 CC||mpolacek at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Marek Polacek --- Confirmed.