[Bug c++/92505] Using mutable in constexpr

2022-09-18 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92505

Patrick Palka  changed:

   What|Removed |Added

   Target Milestone|--- |13.0
 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Patrick Palka  ---
Fixed for GCC 13.

[Bug c++/92505] Using mutable in constexpr

2022-09-16 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92505

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:7107ea6fb933f1e928593c7e92edfd64ccf0df63

commit r13-2701-g7107ea6fb933f1e928593c7e92edfd64ccf0df63
Author: Patrick Palka 
Date:   Fri Sep 16 11:10:43 2022 -0400

c++: 'mutable' member within constexpr [PR92505]

This patch permits accessing 'mutable' members of local objects during
constexpr evaluation, while continuing to reject it for global objects
(as in the last line of cpp0x/constexpr-mutable1.C).  To distinguish
between the two cases, it looks like it suffices to just check
CONSTRUCTOR_MUTABLE_POSION in cxx_eval_component_reference before
deciding to reject a DECL_MUTABLE_P member access.

PR c++/92505

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_component_reference): Check non_constant_p
sooner.  In C++14 or later, reject a DECL_MUTABLE_P member access
only if CONSTRUCTOR_MUTABLE_POISION is also set.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-mutable3.C: New test.
* g++.dg/cpp1y/constexpr-mutable1.C: New test.

[Bug c++/92505] Using mutable in constexpr

2022-09-15 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92505

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org

[Bug c++/92505] Using mutable in constexpr

2021-09-06 Thread arthur.j.odwyer at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92505

Arthur O'Dwyer  changed:

   What|Removed |Added

 CC||arthur.j.odwyer at gmail dot 
com

--- Comment #4 from Arthur O'Dwyer  ---
Confirmed; the test case can be as simple as

// https://godbolt.org/z/M9rf31qqq
struct S { mutable int m; };
static_assert(S{42}.m == 42);

(Removing the "mutable" keyword makes GCC happy.)

[Bug c++/92505] Using mutable in constexpr

2021-07-12 Thread cjdb.ns at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92505

Christopher Di Bella  changed:

   What|Removed |Added

 CC||cjdb.ns at gmail dot com

--- Comment #3 from Christopher Di Bella  ---
Gentle ping, this has started to cause issues in the libc++ GCC CI for ranges.

[Bug c++/92505] Using mutable in constexpr

2019-11-14 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92505

--- Comment #2 from Marek Polacek  ---
cxx_eval_component_reference has:
2967   if (DECL_MUTABLE_P (part))
2968 {
2969   if (!ctx->quiet)
2970 error ("mutable %qD is not usable in a constant expression",
part);
2971   *non_constant_p = true;
2972 }

Added in https://gcc.gnu.org/ml/gcc-patches/2011-10/msg02593.html

I will need to do a bit of archeology on the isocpp mailing list to see the
discussions.

[Bug c++/92505] Using mutable in constexpr

2019-11-14 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92505

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-11-14
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Looks like this never worked.