This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/15851] New: pragma Volatile not respected for variables with default value
- From: "jc at apinc dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jun 2004 17:47:39 -0000
- Subject: [Bug ada/15851] New: pragma Volatile not respected for variables with default value
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In the following code, there is no generated code for testing wether v1 is
really equals to v2, even with the pragma Volatile:
with Ada.Text_IO; use Ada.Text_IO;
procedure bug_volatile is
v1 : Integer := 0;
v2 : Integer := 0;
pragma Volatile (v1);
pragma Volatile (v2);
begin
if v1 = v2 then
Put_Line ("v1 = v2");
end if;
delay 1.0;
if v1 = v2 then
Put_Line ("v1 = v2");
end if;
end bug_volatile;
Neither the first nor the second test are made. I believe both test should be
made, since the values might have been modified by an external event (another
process, another task, hardware, ...) and this is why we made them "volatile".
An equivalent C code actually generates both tests.
GCC version:
Reading specs from /usr/lib/gcc/i486-linux/3.4.0/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,
objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib
--with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib
--enable-nls --enable-threads=posix --without-included-gettext
--program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--disable-werror i486-linux
Thread model: posix
gcc version 3.4.0 (Debian 20040516)
Program was compiled with:
gcc -S bug_volatile.adb
and
gcc -O2 -S bug_volatile.adb
Both commands don't generate code for the tests.
If I didn't give default value, oviously tests are made. However with a warning
during compilation about v1 and v2 never assigned a value. Again this might be
an incorrect warning since we explicitly made variables volatiles, so they *may*
be assigned a value by something else (well, probably giving a warning is
better).
Regards,
JC
--
Summary: pragma Volatile not respected for variables with default
value
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jc at apinc dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15851