This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20912] C++ FE emitting assignments to read-only global symbols
- From: "schlie at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Apr 2005 19:29:04 -0000
- Subject: [Bug c++/20912] C++ FE emitting assignments to read-only global symbols
- References: <20050409015142.20912.dnovillo@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From schlie at comcast dot net 2005-04-18 19:29 -------
(In reply to comment #3)
> Simple code which shows we now have a missed optimization:
> static const double a = 1.0;
> static const double b = a+1.0;
>
> double c()
> {
> return b;
> }
>
> See PR 21089.
I believe the optimization necessitates the variable's declaration be changed
(either explicitly, or by implication):
static const double b = a+1.0; => const double b = a+1.0;
If it's static-const value can't be pre-computed at compile time. (as opposed
to allowing a non-const-literal value to initialize a global static const object).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20912