Talk About Network

Google





Programming > Ada > Re: Feature or ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 13 Topic 5736 of 6006
Post > Topic >>

Re: Feature or Bug? 2#1111# ****fted by 4 is 224

by Ludovic Brenta <ludovic@[EMAIL PROTECTED] > Jun 2, 2008 at 07:59 PM

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.
 




 13 Posts in Topic:
Feature or Bug? 2#1111# shifted by 4 is 224
Dennis Hoppe <dennis.h  2008-06-02 17:17:19 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Tero Koskinen <tero.ko  2008-06-02 19:11:45 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Ludovic Brenta <ludovi  2008-06-03 01:10:25 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Adam Beneschan <adam@[  2008-06-03 10:56:13 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
"Jeffrey R. Carter&q  2008-06-03 19:39:18 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Ludovic Brenta <ludovi  2008-06-02 19:59:33 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Dennis Hoppe <dennis.h  2008-06-02 20:52:26 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
"Jeffrey R. Carter&q  2008-06-03 00:51:29 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Gautier <gautier@[EMAI  2008-06-03 06:26:02 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
"Jeffrey R. Carter&q  2008-06-03 19:36:52 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Samuel Tardieu <sam@[E  2008-06-03 14:59:25 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Gautier <gautier@[EMAI  2008-06-03 00:32:33 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Tero Koskinen <tero.ko  2008-06-04 06:36:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 11:13:31 PST 2009.