comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: strange length check error
Date: Wed, 17 Jan 2018 09:23:44 +0000
Date: 2018-01-17T09:23:44+00:00	[thread overview]
Message-ID: <ly3734alen.fsf@pushface.org> (raw)
In-Reply-To: d90f7446-0adc-4541-8a8e-937997ff8fd7@googlegroups.com

Anh Vo <anhvofrcaus@gmail.com> writes:

> On Tuesday, January 16, 2018 at 12:48:45 PM UTC-8, Mehdi Saada wrote:
>> This : Put(Ch_Bounded1 & ' ' );
>> Calls on that:
>> function "&"
>>      (Left  : in     Bounded_String;
>>       Right : in     Character)
>>       return Bounded_String
>>    is
>>    begin
>>       if LENGTH(LEFT) + 1 > MAX_LENGTH then
>>          raise LENGTH_ERROR with "ERROR '&': LEFT.LENGTH := " & NATURAL'IMAGE(LENGTH(LEFT)) & " + 1 > MAX_LENGTH";
>>       else
>>  @@@     return (LENGTH(LEFT) + 1, LEFT.DATA(1..LENGTH(LEFT)) & RIGHT);
>>       end if;
>>    end "&";
>> 
>> The line with @@@ raises this:
>> raised CONSTRAINT_ERROR : p_bounded_g-p_new_bounded_g.adb:34 length check failed
>> The value of CH_BOUNDED1 at that moment is "pour tester le debut", its length is 21, and MAX_LENGTH est 80.
>
> What is Bounded_String?

I agree. It's not the one from the standard library ((a) it's different,
(b) the standard library doesn't use this ugly, hard to read,
identifiers-in-upper-case style).

This shows why claims that you never need to use the debugger when you
write in Ada are wrong. "What, never?" "Well,hardly ever."


  reply	other threads:[~2018-01-17  9:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 20:48 strange length check error Mehdi Saada
2018-01-17  1:42 ` Anh Vo
2018-01-17  9:23   ` Simon Wright [this message]
2018-01-17 12:13     ` Mehdi Saada
2018-01-17 13:19       ` AdaMagica
2018-01-17 13:41         ` Simon Wright
2018-01-17 21:37           ` Jeffrey R. Carter
2018-01-18 11:12             ` Simon Wright
2018-01-17 13:43         ` Mehdi Saada
2018-01-17 14:03           ` Mehdi Saada
2018-01-17 16:15             ` Mehdi Saada
2018-01-17 19:43               ` Simon Wright
2018-01-17 21:37                 ` Mehdi Saada
2018-01-17 23:00                   ` Niklas Holsti
2018-01-18 11:07                     ` Simon Wright
2018-01-17 13:15     ` Simon Clubley
2018-01-17  8:49 ` Dmitry A. Kazakov
2018-01-23 16:18 ` Robert Eachus
2018-01-23 16:41   ` Mehdi Saada
2018-01-24 16:22     ` Robert Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox