paj@hic.uucp (Paul Johnson) (03/23/90)
The following are a couple of bugs I have come accross while using
Eiffel. In order to save other people the trouble of tracking them
down, I have decided to post them here rather than just sending them
to ISE.
Bug one: the address-of operator "@" on integers produces illegal C code.
----------------------------------------------------------------------
--|
--| Author: Paul Johnson
--|
--| Created: Thu Mar 22 15:23:30 1990
--|
--| Function: This class fails to C-compile.
--|
----------------------------------------------------------------------
indexing
names: bug, address;
class ADDRESS_BUG export
item
feature
Create is
-- Demonstrate a bug.
external
c_foo( x: INTEGER ) language "C";
do
c_foo( @item );
end; -- Create
item: INTEGER;
-- Feature to have its address taken.
end -- class ADDRESS_BUG
The body of the Create function produces the following fragment:
c_foo(
/* item */ &INTDAT(DCurrent[0]));
;
The variable "DCurrent" is not declared. If the "@" is left out of
the call to c_foo then this variable is declared and initialised on
the previous line.
Also, when I first encountered this bug, the symptoms were different.
DCurrent was declared, but the standard C compiler rejected the
argument to "&". Gnu gcc was quite happy with it (hence I am now
using gcc for C compilation). This was probably due to the C function
having another argument whose address was not taken.
Bug 2: Using the "@" operator on local integers fails silently during
pass 4.
----------------------------------------------------------------------
--|
--| Author: Paul Johnson
--|
--| Created: Thu Mar 22 15:39:43 1990
--|
--| Function: This class fails to compile during pass 4.
--|
----------------------------------------------------------------------
indexing
names: local_bug, address;
class LOCAL_BUG export
feature
Create is
-- Demonstrate a bug.
external
c_foo( v: INTEGER ) language "C";
local
i: INTEGER;
do
c_foo( @i );
end; -- Create
end -- class LOCAL_BUG
When compiling this, ec prints out "**Pass 4 cancelled" and stops with
no other explanation. The bug disappears if the "@" sign is removed.
Paul Johnson UUCP: <world>!mcvax!ukc!gec-mrc!paj
--------------------------------!-------------------------|-------------------
GEC-Marconi Research is not | Telex: 995016 GECRES G | Tel: +44 245 73331
responsible for my opinions. | Inet: paj@uk.co.gec-mrc | Fax: +44 245 75244