This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21089] [4.0/4.1 Regression] C++ front-end does not "inline" the static const double
- From: "matz at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Apr 2005 02:46:08 -0000
- Subject: [Bug c++/21089] [4.0/4.1 Regression] C++ front-end does not "inline" the static const double
- References: <20050418172616.21089.matz@suse.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From matz at suse dot de 2005-04-28 02:46 -------
Uhm, wait. Perhaps the optimization would be invalid for your changed example
from comment #5, but see below. But it will not be invalid for my initial testcase,
where it missed to propagate 20.0 into setPosition.
Why I think the transformation is valid _also_ for comment #5: See 3.6.2 #2:
-------------------------------
An implementation is permitted to perform the initialization of an object of namespace scope
with static storage duration as a static initialization even if such initialization is not required to
be done statically, provided that
* the dynamic version of the initialization does not change the
value of any other object of namespace scope with static storage duration prior to its
initialization, and
* the static version of the initialization produces the same value in the
initialized object as would be produced by the dynamic initialization if all objects not required
to be initialized statically were initialized dynamically.
-------------------------------------
It then goes on to provide an example which uses an inline function to dynamically initialize
something, where comment #5 uses an arithmetic expression. So I think we are permitted
to do this optimization, in both, by initial example, and Andrews example from comment #5.
Reopening.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|DUPLICATE |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21089