This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/25521] change semantics of const volatile variables
- From: "gdr at integrable-solutions dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Dec 2005 19:17:51 -0000
- Subject: [Bug middle-end/25521] change semantics of const volatile variables
- References: <bug-25521-700@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from gdr at integrable-solutions dot net 2005-12-21 19:17 -------
Subject: Re: New: change semantics of const volatile variables
"drepper at redhat dot com" <gcc-bugzilla@gcc.gnu.org> writes:
| In math code we often have to make sure the compiler does not fold operations
| at compile time. In glibc we use variable declared as
|
| static const volatile double foo = 42.0;
|
| The problem is that gcc moves such variables into .data. But we could
achieve
| that easily by leaving out the 'const'. What is needed is a method to
achieve
| volatile behavior while having the variable in .rodata (and .rodata.cst8
etc).
|
| I therefore would like to ask for a change in the compiler which preserves
the
| 'const' in the presence of 'volatile' and place the variable in read-only
| memory.
that is tricky because of the general interpretation:
[#10] EXAMPLE 1 An object declared
extern const volatile int real_time_clock;
may be modifiable by hardware, but cannot be assigned to,
incremented, or decremented.
If it may be modified by hardware or other external means, it can't go
into .rodata section.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25521