This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/42239] New: Pragma Inline_Always removes function calls with side effects
- From: "fweimer at bfk dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Dec 2009 13:57:11 -0000
- Subject: [Bug ada/42239] New: Pragma Inline_Always removes function calls with side effects
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following program (to be run through gnatchop) is supposed
to exit with status 17. It exits with status 0 instead. Inspecting
the generated machine code reveals that the call to Close is
not emitted:
0000000000000000 <_ada_u>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: c9 leaveq
5: c3 retq
(This is at -O0, -O2 is similar. Sorry for the misnomer; the test suite
which caught this had an actual close call there; I've changed it to exit
here for easier testing.)
This bug has also been observed with GCC 4.3.4.
with Interfaces.C; use Interfaces.C;
package POSIX_Base is
function C_Close (FD : int) return int;
pragma Import (C, C_Close, "exit");
end POSIX_Base;
with Interfaces.C; use Interfaces.C;
package POSIX is
procedure Close (FD : int);
private
pragma Inline_Always (Close);
end POSIX;
with POSIX_Base; use POSIX_Base;
package body POSIX is
procedure Close (FD : int) is
Status : constant int := C_Close (FD);
pragma Unreferenced (Status);
begin
null;
end;
end POSIX;
with POSIX; use POSIX;
procedure U is
begin
Close (17);
end;
--
Summary: Pragma Inline_Always removes function calls with side
effects
Product: gcc
Version: 4.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fweimer at bfk dot de
GCC build triplet: x86_64-pc-linux-gnu
GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42239