comp.lang.ada
 help / color / mirror / Atom feed
* Enumeration type - GNAT 3.15p bug?
@ 2006-08-17 11:49 Gerd
  2006-08-17 12:03 ` Georg Bauhaus
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Gerd @ 2006-08-17 11:49 UTC (permalink / raw)


Dear all,

I've found some misbehaviour of enumeration types and runtime checking.
Assigning constant values is checked at compile time. For the dynamic
assignment below (line 8) I would expect that an exception is raised,
but nothing happens. I generated an assembly listing and looked at the
code - the runtime check code is generated, but it seems to have a bug
(wrong address calculation).

Does someone know more about it?
- Is there really a bug in GNAT 3.15p?
- Did I do some misinterpretation?

As far as I know the 3.15p was the last officially released version
from AdaCore, wasn't it?



 1: procedure JEnumXa is
 2:   type ex is (Rot, Gruen, Gelb);
 3:
 4:   x : ex;
 5:
 6:   procedure ABC ( i : Integer) is
 7:   begin
 8:     x := ex'VAL(i);
 9:   end ABC;
10: begin
11: null;
12:   x := Rot;
13:   x := Gruen;
14:   x := ex'SUCC (X);
15:   -- x := ex'VAL (99);  -- compiletime error
16:   ABC (99);
17: end JEnumXa;




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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 11:49 Enumeration type - GNAT 3.15p bug? Gerd
@ 2006-08-17 12:03 ` Georg Bauhaus
  2006-08-17 13:19   ` Gerd
  2006-08-17 12:46 ` Dmitry A. Kazakov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Georg Bauhaus @ 2006-08-17 12:03 UTC (permalink / raw)


Gerd wrote:
>  For the dynamic
> assignment below (line 8) I would expect that an exception is raised,

% ./jenumxa 

raised CONSTRAINT_ERROR : jenumxa.adb:8

% gcc -v
Reading specs from /usr/libexec/gcc/darwin/ppc/3.1/specs
Thread model: posix
Apple Computer, Inc. GCC version 1252, based on gcc version 3.1 20021003 (prerelease)

That compiler is not exactly 3.15p, but from 2002, so I guess
it is of a similar age.

Does passing -gnato (Ada mode) to gnatmake make a difference?


> As far as I know the 3.15p was the last officially released version
> from AdaCore, wasn't it?

No, recent official releaes of GNAT can be found here:
https://libre.adacore.com


> 
>  1: procedure JEnumXa is
>  2:   type ex is (Rot, Gruen, Gelb);
>  3:
>  4:   x : ex;

>  8:     x := ex'VAL(i);
>  9:   end ABC;
> 10: begin
 
> 16:   ABC (99);
> 17: end JEnumXa;
> 

-- Georg 



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 11:49 Enumeration type - GNAT 3.15p bug? Gerd
  2006-08-17 12:03 ` Georg Bauhaus
@ 2006-08-17 12:46 ` Dmitry A. Kazakov
  2006-08-17 13:42   ` Gerd
  2006-08-17 18:34 ` Gautier
  2006-08-17 18:37 ` Gautier
  3 siblings, 1 reply; 15+ messages in thread
From: Dmitry A. Kazakov @ 2006-08-17 12:46 UTC (permalink / raw)


On 17 Aug 2006 04:49:55 -0700, Gerd wrote:

> I've found some misbehaviour of enumeration types and runtime checking.
> Assigning constant values is checked at compile time. For the dynamic
> assignment below (line 8) I would expect that an exception is raised,
> but nothing happens. I generated an assembly listing and looked at the
> code - the runtime check code is generated, but it seems to have a bug
> (wrong address calculation).
> 
> Does someone know more about it?
> - Is there really a bug in GNAT 3.15p?
> - Did I do some misinterpretation?
> 
> As far as I know the 3.15p was the last officially released version
> from AdaCore, wasn't it?
> 
>  1: procedure JEnumXa is
>  2:   type ex is (Rot, Gruen, Gelb);
>  3:
>  4:   x : ex;
>  5:
>  6:   procedure ABC ( i : Integer) is
>  7:   begin
>  8:     x := ex'VAL(i);
>  9:   end ABC;
> 10: begin
> 11: null;
> 12:   x := Rot;
> 13:   x := Gruen;
> 14:   x := ex'SUCC (X);
> 15:   -- x := ex'VAL (99);  -- compiletime error
> 16:   ABC (99);
> 17: end JEnumXa;

GNAT 3.15p (Windows):

   raised CONSTRAINT_ERROR : jenumxa.adb:8 overflow check failed

Is it possible that you have suppressed checks?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 12:03 ` Georg Bauhaus
@ 2006-08-17 13:19   ` Gerd
  2006-08-17 18:15     ` Jeffrey R. Carter
  0 siblings, 1 reply; 15+ messages in thread
From: Gerd @ 2006-08-17 13:19 UTC (permalink / raw)



Georg Bauhaus schrieb:

> No, recent official releaes of GNAT can be found here:
> https://libre.adacore.com

There is Ada2006 (which is a standard 2005 version as far as I know)
which has a different licence to 3.15p




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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 12:46 ` Dmitry A. Kazakov
@ 2006-08-17 13:42   ` Gerd
  2006-08-17 18:11     ` Jeffrey R. Carter
  0 siblings, 1 reply; 15+ messages in thread
From: Gerd @ 2006-08-17 13:42 UTC (permalink / raw)



Dmitry A. Kazakov schrieb:

> On 17 Aug 2006 04:49:55 -0700, Gerd wrote:
>
>
> GNAT 3.15p (Windows):
>
>    raised CONSTRAINT_ERROR : jenumxa.adb:8 overflow check failed
>
> Is it possible that you have suppressed checks?

No, checks (all?) are on. Assembly listing shows code for raising
exception, but the compare seem to access a wrong address.




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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 13:42   ` Gerd
@ 2006-08-17 18:11     ` Jeffrey R. Carter
  0 siblings, 0 replies; 15+ messages in thread
From: Jeffrey R. Carter @ 2006-08-17 18:11 UTC (permalink / raw)


Gerd wrote:
> Dmitry A. Kazakov schrieb:
> 
>> On 17 Aug 2006 04:49:55 -0700, Gerd wrote:
>>
>> GNAT 3.15p (Windows):
>>
>>    raised CONSTRAINT_ERROR : jenumxa.adb:8 overflow check failed
>>
>> Is it possible that you have suppressed checks?
> 
> No, checks (all?) are on. Assembly listing shows code for raising
> exception, but the compare seem to access a wrong address.

What platform are you using?

-- 
Jeff Carter
"I'm particularly glad that these lovely children were
here today to hear that speech. Not only was it authentic
frontier gibberish, it expressed a courage little seen
in this day and age."
Blazing Saddles
88



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 13:19   ` Gerd
@ 2006-08-17 18:15     ` Jeffrey R. Carter
  0 siblings, 0 replies; 15+ messages in thread
From: Jeffrey R. Carter @ 2006-08-17 18:15 UTC (permalink / raw)


Gerd wrote:
> 
> There is Ada2006 (which is a standard 2005 version as far as I know)
> which has a different licence to 3.15p

Actually, it's an Ada-95 compiler. There's an option which allows some 
features from the Ada 0X draft standard.

It does have a different license than 3.15p. 3.15p is the most recent 
AdaCore public release with the GMGPL run time.

-- 
Jeff Carter
"I'm particularly glad that these lovely children were
here today to hear that speech. Not only was it authentic
frontier gibberish, it expressed a courage little seen
in this day and age."
Blazing Saddles
88



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 11:49 Enumeration type - GNAT 3.15p bug? Gerd
  2006-08-17 12:03 ` Georg Bauhaus
  2006-08-17 12:46 ` Dmitry A. Kazakov
@ 2006-08-17 18:34 ` Gautier
  2006-08-17 18:37 ` Gautier
  3 siblings, 0 replies; 15+ messages in thread
From: Gautier @ 2006-08-17 18:34 UTC (permalink / raw)


I guess you have a run-time check or a -gnatp somewhere. If I compile 
your code with GNAT 3.15p (20020523), I obtain the expected behaviour 
(even without extra integer checks via -gnato):

C:\WINDOWS\Bureau>gnatmake -f jenumxa.adb
gcc -c jenumxa.adb
gnatbind -x jenumxa.ali
gnatlink jenumxa.ali

C:\WINDOWS\Bureau>jenumxa

raised CONSTRAINT_ERROR : jenumxa.adb:8 overflow check failed

By suppressing run-time checks (-gnatp), I obtain:

C:\WINDOWS\Bureau>gnatmake -f -gnatp jenumxa.adb
gcc -c -gnatp jenumxa.adb
gnatbind -x jenumxa.ali
gnatlink jenumxa.ali

C:\WINDOWS\Bureau>jenumxa

C:\WINDOWS\Bureau>

Probably you'd better to mention the exact options you passed to the 
compiler. Anyway, I've never seen that kind of bug in GNAT (user since 
the 3.07p version (~1996)!)...

HTH, Gautier
_______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 11:49 Enumeration type - GNAT 3.15p bug? Gerd
                   ` (2 preceding siblings ...)
  2006-08-17 18:34 ` Gautier
@ 2006-08-17 18:37 ` Gautier
  2006-08-18  8:25   ` Gerd
  3 siblings, 1 reply; 15+ messages in thread
From: Gautier @ 2006-08-17 18:37 UTC (permalink / raw)


I guess you have a run-time check suppression or a -gnatp somewhere. 
If I compile your code with GNAT 3.15p (20020523), I obtain the 
expected behaviour (even without extra integer checks via -gnato):

C:\WINDOWS\Bureau>gnatmake -f jenumxa.adb
gcc -c jenumxa.adb
gnatbind -x jenumxa.ali
gnatlink jenumxa.ali

C:\WINDOWS\Bureau>jenumxa

raised CONSTRAINT_ERROR : jenumxa.adb:8 overflow check failed

By suppressing run-time checks (-gnatp), I obtain:

C:\WINDOWS\Bureau>gnatmake -f -gnatp jenumxa.adb
gcc -c -gnatp jenumxa.adb
gnatbind -x jenumxa.ali
gnatlink jenumxa.ali

C:\WINDOWS\Bureau>jenumxa

C:\WINDOWS\Bureau>

Probably you'd better to mention the exact options you passed to the 
compiler. Anyway, I've never seen that kind of bug in GNAT (user since 
the 3.07p version (~1996)!)...

HTH, Gautier
_______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-17 18:37 ` Gautier
@ 2006-08-18  8:25   ` Gerd
  2006-08-19  2:53     ` Gautier
  0 siblings, 1 reply; 15+ messages in thread
From: Gerd @ 2006-08-18  8:25 UTC (permalink / raw)



Gautier schrieb:
> Probably you'd better to mention the exact options you passed to the
> compiler. Anyway, I've never seen that kind of bug in GNAT (user since
> the 3.07p version (~1996)!)...
>

I've compiled it with AdaGIDE with all checks enabled (Debug settings).
The output looks like this:

 GNATMAKE 3.15p  (20020523) Copyright 1995-2002 Free Software
Foundation, Inc.
 gcc -c -Ic:/projekte/ada95/testenum/ -gnatwu -g -gnato -fstack-check
-gnatX -IC:\Projekte\
Ada95\TestEnum -g -I- c:/projekte/ada95/testenum/testenum.adb

The check-code is generated, but it doesn't work correct. I will post
it again when I'm at home - source, settings and assembly listing.

I work on Windows XP SP1, some friends found the same with Win2k.

Gerd




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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-18  8:25   ` Gerd
@ 2006-08-19  2:53     ` Gautier
  2006-08-19 20:50       ` Gerd
  0 siblings, 1 reply; 15+ messages in thread
From: Gautier @ 2006-08-19  2:53 UTC (permalink / raw)


>> Probably you'd better to mention the exact options you passed to the
>> compiler. Anyway, I've never seen that kind of bug in GNAT (user since
>> the 3.07p version (~1996)!)...
> 
> I've compiled it with AdaGIDE with all checks enabled (Debug settings).
> The output looks like this:
> 
>  GNATMAKE 3.15p  (20020523) Copyright 1995-2002 Free Software
> Foundation, Inc.
>  gcc -c -Ic:/projekte/ada95/testenum/ -gnatwu -g -gnato -fstack-check
> -gnatX -IC:\Projekte\
> Ada95\TestEnum -g -I- c:/projekte/ada95/testenum/testenum.adb
> 
> The check-code is generated, but it doesn't work correct. I will post
> it again when I'm at home - source, settings and assembly listing.
> 
> I work on Windows XP SP1, some friends found the same with Win2k.

OK, I test it on Windows XP SP2 (previous one was on Windows 98 SE),
with exactly your options (and from AdaGIDE :-):

gcc -c -Iz:/ -gnatwu -g -gnato -fstack-check -gnatX -IZ: -g -I- 
z:/jenumxa.adb

and...

raised CONSTRAINT_ERROR : jenumxa.adb:8 overflow check failed

Is it possible that you have a version mix, like GNAT 3.15p but also 
another GCC with another as, ld or run-time library components ?
What comes first in the PATH ?
HTH, G.
_______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-19  2:53     ` Gautier
@ 2006-08-19 20:50       ` Gerd
  2006-08-20  9:27         ` Gautier
  0 siblings, 1 reply; 15+ messages in thread
From: Gerd @ 2006-08-19 20:50 UTC (permalink / raw)



Gautier schrieb:

> > I've compiled it with AdaGIDE with all checks enabled (Debug settings).
> >
> > The check-code is generated, but it doesn't work correct. I will post
> > it again when I'm at home - source, settings and assembly listing.
>
> OK, I test it on Windows XP SP2 (previous one was on Windows 98 SE),
> with exactly your options (and from AdaGIDE :-):
>


I've found some more details.

1. Create a new directory.
2. Copy the source into.
3. Start AdaGIDE, select "Project settings", write -S (for assembly
listing) into "Compiler options".
4. Press F3. The program will fail to link: "undefined reference to
_ada_jenumxa".

If you remove the -S from the options it works. Add the -S again, and
you will get many different misbehaviours from now on.

Gerd




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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-19 20:50       ` Gerd
@ 2006-08-20  9:27         ` Gautier
  2006-08-28 13:54           ` Gerd
  0 siblings, 1 reply; 15+ messages in thread
From: Gautier @ 2006-08-20  9:27 UTC (permalink / raw)


Gerd:

> I've found some more details.
> 
> 1. Create a new directory.
> 2. Copy the source into.
> 3. Start AdaGIDE, select "Project settings", write -S (for assembly
> listing) into "Compiler options".

OK, now I have the explanation... The "-S" option means STOP:

-S
     Stop after the stage of compilation proper; do not assemble. The 
output is in the form of an assembler code file for each non-assembler 
input file specified.

-> http://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html

> 4. Press F3. The program will fail to link: "undefined reference to
> _ada_jenumxa".

That's normal, jenumxa.s is produced, not jenumxa.o

> If you remove the -S from the options it works. Add the -S again, and
> you will get many different misbehaviours from now on.

Possible, given the above...
HTH, Gautier
_______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-20  9:27         ` Gautier
@ 2006-08-28 13:54           ` Gerd
  2006-08-29  1:17             ` Gautier
  0 siblings, 1 reply; 15+ messages in thread
From: Gerd @ 2006-08-28 13:54 UTC (permalink / raw)



Gautier schrieb:

> > 3. Start AdaGIDE, select "Project settings", write -S (for assembly
> > listing) into "Compiler options".
>
> OK, now I have the explanation... The "-S" option means STOP:
>
> -S
>      Stop after the stage of compilation proper; do not assemble. The
> output is in the form of an assembler code file for each non-assembler
> input file specified.
>
> -> http://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html
>
> > 4. Press F3. The program will fail to link: "undefined reference to
> > _ada_jenumxa".
>
> That's normal, jenumxa.s is produced, not jenumxa.o
>
> > If you remove the -S from the options it works. Add the -S again, and
> > you will get many different misbehaviours from now on.


OK, you're right. Removing the -S did it.

Nevertheless I would expect that either AdaGIDE or gnatmake (or someone
else) *stop* after compile instead of running the linker although GNAT
didn't generate code. Otherwise it's confusing.

Gerd




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

* Re: Enumeration type - GNAT 3.15p bug?
  2006-08-28 13:54           ` Gerd
@ 2006-08-29  1:17             ` Gautier
  0 siblings, 0 replies; 15+ messages in thread
From: Gautier @ 2006-08-29  1:17 UTC (permalink / raw)


Gerd:

> OK, you're right. Removing the -S did it.
> 
> Nevertheless I would expect that either AdaGIDE or gnatmake (or someone
> else) *stop* after compile instead of running the linker although GNAT
> didn't generate code. Otherwise it's confusing.

That's right, and it should be gnatmake's job: since it figures out what 
source must be recompiled according to time-stamps, it should verify that an 
up-to-date object has effectively been produced or at least not try to go 
further when "-S" has been passed.
But maybe there is some reason behind current behaviour; there is the 
following gnatmake option (in 3.15p too):
   -s       Recompile if compiler switches have changed
Of course it wouldn't solve the problem if there is a "-S" around!
Maybe it is solved in more recent GNATs. If not, it could be useful to write 
to report@gnat.com about it. An option in gcc for creating .o but leaving the 
.s file (which is created anyway as temp file) would be optimal.

Not waiting that gnat or gcc solves it, it could be also added to AdaGIDE 
(I'll take a look :-) ).
______________________________________________________________
Gautier         -- http://www.mysunrise.ch/users/gdm/index.htm
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



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

end of thread, other threads:[~2006-08-29  1:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-17 11:49 Enumeration type - GNAT 3.15p bug? Gerd
2006-08-17 12:03 ` Georg Bauhaus
2006-08-17 13:19   ` Gerd
2006-08-17 18:15     ` Jeffrey R. Carter
2006-08-17 12:46 ` Dmitry A. Kazakov
2006-08-17 13:42   ` Gerd
2006-08-17 18:11     ` Jeffrey R. Carter
2006-08-17 18:34 ` Gautier
2006-08-17 18:37 ` Gautier
2006-08-18  8:25   ` Gerd
2006-08-19  2:53     ` Gautier
2006-08-19 20:50       ` Gerd
2006-08-20  9:27         ` Gautier
2006-08-28 13:54           ` Gerd
2006-08-29  1:17             ` Gautier

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