[Bug c++/86608] [6/7/8/9 Regression] volatile variable is taken as a constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86608 --- Comment #3 from Marek Polacek --- Hmm, but I'm not happy about the error it produces, better use non_const_var_error somehow.
[Bug c++/86608] [6/7/8/9 Regression] volatile variable is taken as a constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86608 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #2 from Marek Polacek --- This seems to fix it, will test tomorrow EDT. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 365296d6e3b..70c433c5061 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5351,7 +5351,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, if (t == NULL_TREE) return true; location_t loc = cp_expr_loc_or_loc (t, input_location); - if (TREE_THIS_VOLATILE (t) && !DECL_P (t)) + if (TREE_THIS_VOLATILE (t)) { if (flags & tf_error) error_at (loc, "expression %qE has side-effects", t); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65327.C b/gcc/testsuite/g++.dg/cpp0x/pr65327.C index c6cefaba692..8a5ee492097 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr65327.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr65327.C @@ -15,4 +15,4 @@ constexpr volatile int bar () { return i; -} +} // { dg-error "expression .i. has side-effects" }
[Bug c++/86608] [6/7/8/9 Regression] volatile variable is taken as a constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86608 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-07-30 CC||jason at redhat dot com Known to work||5.4.0 Summary|volatile variable is taken |[6/7/8/9 Regression] |as a constexpr |volatile variable is taken ||as a constexpr Ever confirmed|0 |1 Known to fail||6.4.0, 7.3.0, 8.2.0, 9.0 --- Comment #1 from Jonathan Wakely --- Regression started with r231351: Fix template/ref1.C, nontype15.C, addr-builtin1.C with -std=c++1z. * parser.c (cp_parser_template_argument): Handle references in C++1z mode. * constexpr.c (potential_constant_expression_1): Don't error about TREE_THIS_VOLATILE on declarations. [COMPONENT_REF]: Don't consider the object if we're dealing with an overloaded function.