comp.lang.ada
 help / color / mirror / Atom feed
* Is this definition legal?
@ 2004-09-18 23:29 Björn Persson
  2004-09-18 23:44 ` Ludovic Brenta
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Björn Persson @ 2004-09-18 23:29 UTC (permalink / raw)


GCC-Gnat 3.4.0 is having serious problems with the definition of 
Character_Encoding below:

  type Known_OS is (NT, OS2, Linux);

  This_OS : constant Known_OS := Linux;

  type Encoding_ID is
    (UTF_8_ID, ASCII_ID, Latin_1_ID);  -- and some others

  type Unified_Encoding_Record (Known : Boolean; OS : Known_OS) is record
     case Known is
        when True =>
           Which : Encoding_ID;
        when False =>
           case OS is
              when Linux =>
                 Name : Unbounded_String;
              when NT | OS2 =>
                 Number : Unsigned_16;
           end case;
     end case;
  end record;

  type Character_Encoding (Known : Boolean := False) is
    new Unified_Encoding_Record (Known => Known, OS => This_OS);

Gnat often crashes with a bug box on a reference to Character_Encoding. 
For example, when I declare a variable of this type I have to initialize 
it at the declaration to avoid a bug box. Also, the predefined "=" for 
Character_Encoding sometimes returns False for values that should be equal.

Once when I converted a Character_Encoding to a Unified_Encoding_Record, 
the field OS was set to NT, even though This_OS = Linux. The next 
conversion raised Constraint_Error with the message "invalid data".

My first question is: Is this definition of Character_Encoding legal and 
I should work around the problems until Gnat gets fixed, or is it 
illegal code that Gnat fails to reject, and I should find another way to 
do it?

I have also seen an indication that Adjust gets called on the field Name 
(Unbounded_String is controlled), even when Known is True, and this is 
my second question: Should I expect that fields in a variant part are 
"active" like this even when they are inaccessible because of the 
discriminant's value? It seems like waste of time to call procedures to 
maintain a value that can never be read.

-- 
Björn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-18 23:29 Is this definition legal? Björn Persson
@ 2004-09-18 23:44 ` Ludovic Brenta
  2004-09-19 14:07   ` Björn Persson
  2004-09-19 14:17   ` Björn Persson
  2004-09-19  8:42 ` Martin Krischik
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 16+ messages in thread
From: Ludovic Brenta @ 2004-09-18 23:44 UTC (permalink / raw)


Björn Persson writes:
> GCC-Gnat 3.4.0 is having serious problems with the definition of
> Character_Encoding below:

[elided]

> Gnat often crashes with a bug box on a reference to
> Character_Encoding. For example, when I declare a variable of this
> type I have to initialize it at the declaration to avoid a bug
> box. Also, the predefined "=" for Character_Encoding sometimes
> returns False for values that should be equal.
>
> Once when I converted a Character_Encoding to a
> Unified_Encoding_Record, the field OS was set to NT, even though
> This_OS = Linux. The next conversion raised Constraint_Error with
> the message "invalid data".

Whether or not your code is legal, a bug box is a bug.  I would be
interested in a short test case for each of your issues (one for the
bug box upon declaring a Character_Encoding without an initialiser;
one for the conversion that alters OS, and one where the conversions
raises Constraint_Error.

> My first question is: Is this definition of Character_Encoding legal
> and I should work around the problems until Gnat gets fixed, or is
> it illegal code that Gnat fails to reject, and I should find another
> way to do it?

Sorry, I don't know.  It seems okay to me at first glance, but I've
been wrong about such things before :)

-- 
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-18 23:29 Is this definition legal? Björn Persson
  2004-09-18 23:44 ` Ludovic Brenta
@ 2004-09-19  8:42 ` Martin Krischik
  2004-09-19 11:25   ` Simon Wright
  2004-09-19 11:30 ` Simon Wright
  2004-09-19 11:53 ` Martin Dowie
  3 siblings, 1 reply; 16+ messages in thread
From: Martin Krischik @ 2004-09-19  8:42 UTC (permalink / raw)


Bjï¿œrn Persson wrote:

> My first question is: Is this definition of Character_Encoding legal and

"Legal" questions should be send to  ada-comment@ada-auth.org. They are the
guys who can not only "advice" but also "decide" on such issues.

Of course you should join the list (listserv@ada-auth.org) otherwise you
never see the answer.

With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-19  8:42 ` Martin Krischik
@ 2004-09-19 11:25   ` Simon Wright
  2004-09-20  7:32     ` Martin Krischik
  0 siblings, 1 reply; 16+ messages in thread
From: Simon Wright @ 2004-09-19 11:25 UTC (permalink / raw)


Martin Krischik <krischik@users.sourceforge.net> writes:

> "Legal" questions should be send to ada-comment@ada-auth.org. They
> are the guys who can not only "advice" but also "decide" on such
> issues.

I'm not sure this is good advice, isn't that list for discussion of
proposals for changes to the standard?

-- 
Simon Wright                               100% Ada, no bugs.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-18 23:29 Is this definition legal? Björn Persson
  2004-09-18 23:44 ` Ludovic Brenta
  2004-09-19  8:42 ` Martin Krischik
@ 2004-09-19 11:30 ` Simon Wright
  2004-09-19 11:53 ` Martin Dowie
  3 siblings, 0 replies; 16+ messages in thread
From: Simon Wright @ 2004-09-19 11:30 UTC (permalink / raw)


5.02a1 gives a bug box too.

-- 
Simon Wright                               100% Ada, no bugs.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-18 23:29 Is this definition legal? Björn Persson
                   ` (2 preceding siblings ...)
  2004-09-19 11:30 ` Simon Wright
@ 2004-09-19 11:53 ` Martin Dowie
  3 siblings, 0 replies; 16+ messages in thread
From: Martin Dowie @ 2004-09-19 11:53 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 164 bytes --]

Bj�rn Persson wrote:
> GCC-Gnat 3.4.0 is having serious problems with the definition of
> Character_Encoding below:

Compiles fine on ObjectAda 7.2.2 (U14). 





^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-18 23:44 ` Ludovic Brenta
@ 2004-09-19 14:07   ` Björn Persson
  2004-09-19 20:21     ` Ludovic Brenta
  2004-09-23 21:18     ` Björn Persson
  2004-09-19 14:17   ` Björn Persson
  1 sibling, 2 replies; 16+ messages in thread
From: Björn Persson @ 2004-09-19 14:07 UTC (permalink / raw)


Ludovic Brenta wrote:

> Whether or not your code is legal, a bug box is a bug.  I would be
> interested in a short test case for each of your issues (one for the
> bug box upon declaring a Character_Encoding without an initialiser;

That one is easy:

with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces; use Interfaces;

package Declaration_Bug_Box is

    type Known_OS is (NT, OS2, Linux);

    This_OS : constant Known_OS := Linux;

    type Encoding_ID is
      (UTF_8_ID, ASCII_ID, Latin_1_ID);

    type Unified_Encoding_Record (Known : Boolean; OS : Known_OS) is record
       case Known is
          when True =>
             Which : Encoding_ID;
          when False =>
             case OS is
                when Linux =>
                   Name : Unbounded_String;
                when NT | OS2 =>
                   Number : Unsigned_16;
             end case;
       end case;
    end record;

    type Character_Encoding (Known : Boolean := False) is
      new Unified_Encoding_Record (Known => Known, OS => This_OS);

    Trigger_Bug : Character_Encoding;

end Declaration_Bug_Box;

> one for the conversion that alters OS, and one where the conversions
> raises Constraint_Error.

Those are difficult to reproduce. I think they depend on uninitialized 
memory and I haven't quite figured out which constant, variable or 
parameter it is that doesn't get properly initialized. I'd need a way to 
reliably "pre-initialize" memory - that is, to make sure that the right 
kind of garbage is present before a variable or constant is created. I'm 
working on it.

-- 
Björn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-18 23:44 ` Ludovic Brenta
  2004-09-19 14:07   ` Björn Persson
@ 2004-09-19 14:17   ` Björn Persson
  1 sibling, 0 replies; 16+ messages in thread
From: Björn Persson @ 2004-09-19 14:17 UTC (permalink / raw)


Ludovic Brenta wrote:

I forgot to mention, I think you should also be aware of this bug report 
that I made the first time I got a bug box related to this type:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17160

-- 
Björn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-19 14:07   ` Björn Persson
@ 2004-09-19 20:21     ` Ludovic Brenta
  2004-09-23 21:18     ` Björn Persson
  1 sibling, 0 replies; 16+ messages in thread
From: Ludovic Brenta @ 2004-09-19 20:21 UTC (permalink / raw)


Björn Persson writes:
> Ludovic Brenta wrote:
>
>> Whether or not your code is legal, a bug box is a bug.  I would be
>> interested in a short test case for each of your issues (one for the
>> bug box upon declaring a Character_Encoding without an initialiser;
>
> That one is easy:

[elided]

It compiles fine with gnat_3.15p-12 on Debian, but gives the bug box
with 3.4.2-2.

I added comments to that effect in Bugzilla, and also attached your
shorter test case.

-- 
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-19 11:25   ` Simon Wright
@ 2004-09-20  7:32     ` Martin Krischik
  2004-09-20 13:44       ` Björn Persson
  2004-09-20 17:12       ` Florian Weimer
  0 siblings, 2 replies; 16+ messages in thread
From: Martin Krischik @ 2004-09-20  7:32 UTC (permalink / raw)


Simon Wright wrote:

> Martin Krischik <krischik@users.sourceforge.net> writes:
> 
>> "Legal" questions should be send to ada-comment@ada-auth.org. They
>> are the guys who can not only "advice" but also "decide" on such
>> issues.
> 
> I'm not sure this is good advice, isn't that list for discussion of
> proposals for changes to the standard?

Currently it is mostly a "Ada.Containers" discussion list. But is is a list
for both changes and clarifications.

With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-20  7:32     ` Martin Krischik
@ 2004-09-20 13:44       ` Björn Persson
  2004-09-20 16:01         ` Martin Krischik
  2004-09-20 21:20         ` Randy Brukardt
  2004-09-20 17:12       ` Florian Weimer
  1 sibling, 2 replies; 16+ messages in thread
From: Björn Persson @ 2004-09-20 13:44 UTC (permalink / raw)


Martin Krischik wrote:

> Simon Wright wrote:
> 
>>Martin Krischik <krischik@users.sourceforge.net> writes:
>>
>>>"Legal" questions should be send to ada-comment@ada-auth.org. They
>>>are the guys who can not only "advice" but also "decide" on such
>>>issues.
>>
>>I'm not sure this is good advice, isn't that list for discussion of
>>proposals for changes to the standard?
> 
> Currently it is mostly a "Ada.Containers" discussion list. But is is a list
> for both changes and clarifications.

I thought Ada-comment would be appropriate if I could point to a 
paragraph in the reference manual that needed clarification. That's not 
the case. Anyway, if ObjectAda and Gnat 3.15p accept the code, I suppose 
it's legal.

-- 
Björn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-20 13:44       ` Björn Persson
@ 2004-09-20 16:01         ` Martin Krischik
  2004-09-20 21:20         ` Randy Brukardt
  1 sibling, 0 replies; 16+ messages in thread
From: Martin Krischik @ 2004-09-20 16:01 UTC (permalink / raw)


Bjï¿œrn Persson wrote:

> Martin Krischik wrote:
> 
>> Simon Wright wrote:
>> 
>>>Martin Krischik <krischik@users.sourceforge.net> writes:
>>>
>>>>"Legal" questions should be send to ada-comment@ada-auth.org. They
>>>>are the guys who can not only "advice" but also "decide" on such
>>>>issues.
>>>
>>>I'm not sure this is good advice, isn't that list for discussion of
>>>proposals for changes to the standard?
>> 
>> Currently it is mostly a "Ada.Containers" discussion list. But is is a
>> list for both changes and clarifications.
> 
> I thought Ada-comment would be appropriate if I could point to a
> paragraph in the reference manual that needed clarification. That's not
> the case. Anyway, if ObjectAda and Gnat 3.15p accept the code, I suppose
> it's legal.

Normal people don't have to point a paragraph to ask the language lawyers.
Usually it is the other way round. You asked a question and language
lawyers point out the paragraph and clarify it.

Nobody has been called names there.

With Regards

Martin

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-20  7:32     ` Martin Krischik
  2004-09-20 13:44       ` Björn Persson
@ 2004-09-20 17:12       ` Florian Weimer
  2004-09-21  7:58         ` Martin Krischik
  1 sibling, 1 reply; 16+ messages in thread
From: Florian Weimer @ 2004-09-20 17:12 UTC (permalink / raw)


* Martin Krischik:

> Currently it is mostly a "Ada.Containers" discussion list. But is is a list
> for both changes and clarifications.

It's not clear if a clarification of the standard is needed here.
Surely ada-comment is not the list to ask random questions about the
standard!



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-20 13:44       ` Björn Persson
  2004-09-20 16:01         ` Martin Krischik
@ 2004-09-20 21:20         ` Randy Brukardt
  1 sibling, 0 replies; 16+ messages in thread
From: Randy Brukardt @ 2004-09-20 21:20 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

"Bj�rn Persson" <spam-away@nowhere.nil> wrote in message
news:S8B3d.3680$d5.28757@newsb.telia.net...

>I thought Ada-comment would be appropriate if I could point to a
>paragraph in the reference manual that needed clarification. That's not
>the case.

You're right in the sense that Ada-Comment is not a place for asking random
questions about code. If a compiler had rejected the code and cited some
paragraph in the standard, you certainly could (and should) ask about it.
But its definitely not a place to discuss bug boxes in particular compilers.

               Randy Brukardt
               ARG Editor






^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-20 17:12       ` Florian Weimer
@ 2004-09-21  7:58         ` Martin Krischik
  0 siblings, 0 replies; 16+ messages in thread
From: Martin Krischik @ 2004-09-21  7:58 UTC (permalink / raw)


Florian Weimer wrote:

> * Martin Krischik:
> 
>> Currently it is mostly a "Ada.Containers" discussion list. But is is a
>> list for both changes and clarifications.
> 
> It's not clear if a clarification of the standard is needed here.

True - most of us have agreed it is a compiler bug.

> Surely ada-comment is not the list to ask random questions about the
> standard!

Sure - Beginners questions should not be ask at ada-comment. I see it like
this: If nobody at here c.l.a knows the answer then the question is
sufficiently complex or the answer sufficiently hidden in the RM for query
at ada-comment.

So in that respect Bjï¿œrn did of corse do the right think to raise question
here first.

With Rergards

Martin

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Is this definition legal?
  2004-09-19 14:07   ` Björn Persson
  2004-09-19 20:21     ` Ludovic Brenta
@ 2004-09-23 21:18     ` Björn Persson
  1 sibling, 0 replies; 16+ messages in thread
From: Björn Persson @ 2004-09-23 21:18 UTC (permalink / raw)


Björn Persson wrote:

> Ludovic Brenta wrote:
>
>> one for the conversion that alters OS, and one where the conversions
>> raises Constraint_Error.
> 
> Those are difficult to reproduce. I think they depend on uninitialized 
> memory and I haven't quite figured out which constant, variable or 
> parameter it is that doesn't get properly initialized. I'd need a way to 
> reliably "pre-initialize" memory - that is, to make sure that the right 
> kind of garbage is present before a variable or constant is created. I'm 
> working on it.

I have submitted two test programs to Bugzilla.

-- 
Björn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-09-23 21:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-18 23:29 Is this definition legal? Björn Persson
2004-09-18 23:44 ` Ludovic Brenta
2004-09-19 14:07   ` Björn Persson
2004-09-19 20:21     ` Ludovic Brenta
2004-09-23 21:18     ` Björn Persson
2004-09-19 14:17   ` Björn Persson
2004-09-19  8:42 ` Martin Krischik
2004-09-19 11:25   ` Simon Wright
2004-09-20  7:32     ` Martin Krischik
2004-09-20 13:44       ` Björn Persson
2004-09-20 16:01         ` Martin Krischik
2004-09-20 21:20         ` Randy Brukardt
2004-09-20 17:12       ` Florian Weimer
2004-09-21  7:58         ` Martin Krischik
2004-09-19 11:30 ` Simon Wright
2004-09-19 11:53 ` Martin Dowie

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