Tero Koskinen <tero.koskinen@[EMAIL PROTECTED]
> writes:
> On Mon, 02 Jun 2008 17:17:19 +0200 Dennis Hoppe wrote:
>> Hi,
>>
>> we probably found a bug in Ada or we cannot realize, that this is
indeed
>> a feature ;)
> [snip]
>>
>> In Example B, we limit the parameter N to Positive, because we do not
>> want "negative" ****fts. The result of ****ft_Left(2#1111#, 4) is 224
>> (2#11100000#) !
>>
>> -- Example B
>> type Modular_Type is mod 2**4;
>> function ****ft_Left (Item : in Modular_Type;
>> N : in Positive) return Modular_Type is
>> begin
>> return Item * 2**N;
>> end ****ft_Left;
>>
>> Why does this happen?
>
> It is a bug in GCC on i386 platform. I can repeat it with GNAT GPL 2007
> and GCC 4.3.0 (OpenBSD/i386). With GCC 4.3.0 optimization flags
> (-O2 vs. -O0) seem to affect to the result.
>
> On Solaris (5.10 Generic_127111-05 sun4u sparc SUNW,Sun-Fire-V240) with
> GCC 4.2.1 the example returns 0 always.
>
> Here is more complete test case:
> with Ada.Text_IO; use Ada.Text_IO;
> procedure ****ft is
>
> type Modular_Type is mod 2**4;
> function ****ft_Left (Item : in Modular_Type;
> N : in Positive) return Modular_Type is
> begin
> return Item * (2**N);
> end ****ft_Left;
>
> X : Modular_Type;
> begin
> X := ****ft_Left(2#1111#, 4);
> Put_Line (X'Img);
> end ****ft;
This looks like http://gcc.gnu.org/PR30740
which is fixed in Debian
unstable :)
Could you confirm that this is the same bug indeed?
--
Ludovic Brenta.


|