comp.lang.ada
 help / color / mirror / Atom feed
* bug compiler ?
@ 2017-06-30  8:49 bbaborum
  2017-06-30 11:09 ` Lucretia
  2017-06-30 15:11 ` AdaMagica
  0 siblings, 2 replies; 10+ messages in thread
From: bbaborum @ 2017-06-30  8:49 UTC (permalink / raw)


Hello everyone,

I tried to compile this 

procedure bug is
	type my_int is new integer;
	type access_function_my_int is access function (n : my_int) return my_int;
	function f (n : my_int) return my_int is (n);
	a : access_function_my_int :=f'access;
begin
	null;
end bug;

with the command line : gcc -c -gnat2012 bug.adb

and then I get this message from the compiler:


raised STORAGE_ERROR : stack overflow or erroneous memory access

If I modify the type "my_int" by writing subtype my_int is integer;
then I dont get any error from the compiler.

More interesting, if in the first program, the function f is no longer written inline, then I dont get any error.

Does anyone know what's happeing ?	

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

* Re: bug compiler ?
  2017-06-30  8:49 bug compiler ? bbaborum
@ 2017-06-30 11:09 ` Lucretia
  2017-06-30 14:49   ` Anh Vo
  2017-07-02 16:42   ` bbaborum
  2017-06-30 15:11 ` AdaMagica
  1 sibling, 2 replies; 10+ messages in thread
From: Lucretia @ 2017-06-30 11:09 UTC (permalink / raw)


On Friday, 30 June 2017 09:49:59 UTC+1, bbab...@gmail.com  wrote:
> Hello everyone,
> 
> I tried to compile this 
> 
> procedure bug is
> 	type my_int is new integer;
> 	type access_function_my_int is access function (n : my_int) return my_int;
> 	function f (n : my_int) return my_int is (n);
> 	a : access_function_my_int :=f'access;
> begin
> 	null;
> end bug;
> 
> with the command line : gcc -c -gnat2012 bug.adb
> 
> and then I get this message from the compiler:
> 
> 
> raised STORAGE_ERROR : stack overflow or erroneous memory access
> 
> If I modify the type "my_int" by writing subtype my_int is integer;
> then I dont get any error from the compiler.
> 
> More interesting, if in the first program, the function f is no longer written inline, then I dont get any error.
> 
> Does anyone know what's happeing ?

You can't create a local pointer to f or anything there, you have to define it in a package. You're essentially trying to create a pointer on the stack to something else on the stack. There is a way around it, I think unchecked_conversion, not sure now.

Luke.

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

* Re: bug compiler ?
  2017-06-30 11:09 ` Lucretia
@ 2017-06-30 14:49   ` Anh Vo
  2017-06-30 15:03     ` Anh Vo
  2017-06-30 18:47     ` Simon Wright
  2017-07-02 16:42   ` bbaborum
  1 sibling, 2 replies; 10+ messages in thread
From: Anh Vo @ 2017-06-30 14:49 UTC (permalink / raw)


On Friday, June 30, 2017 at 4:09:31 AM UTC-7, Lucretia wrote:
> On Friday, 30 June 2017 09:49:59 UTC+1, bbab...@gmail.com  wrote:
> > Hello everyone,
> > 
> > I tried to compile this 
> > 
> > procedure bug is
> > 	type my_int is new integer;
> > 	type access_function_my_int is access function (n : my_int) return my_int;
> > 	function f (n : my_int) return my_int is (n);
> > 	a : access_function_my_int :=f'access;
> > begin
> > 	null;
> > end bug;
> > 
> > with the command line : gcc -c -gnat2012 bug.adb
> > 
> > and then I get this message from the compiler:
> > 
> > 
> > raised STORAGE_ERROR : stack overflow or erroneous memory access
> > 
> > If I modify the type "my_int" by writing subtype my_int is integer;
> > then I dont get any error from the compiler.
> > 
> > More interesting, if in the first program, the function f is no longer written inline, then I dont get any error.
> > 
> > Does anyone know what's happeing ?
> 
> You can't create a local pointer to f or anything there, you have to define it in a package. You're essentially trying to create a pointer on the stack to something else on the stack. There is a way around it, I think unchecked_conversion, not sure now.
> 

The compiler should reject it if it does not compile with syntax rule. In this case, it does compile. In fact, if the function expression is replaced by normal function, it compiles fine. 

Therefore, a bug report should be sent to gnat@adacore.com.

Anh Vo

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

* Re: bug compiler ?
  2017-06-30 14:49   ` Anh Vo
@ 2017-06-30 15:03     ` Anh Vo
  2017-06-30 18:47     ` Simon Wright
  1 sibling, 0 replies; 10+ messages in thread
From: Anh Vo @ 2017-06-30 15:03 UTC (permalink / raw)


On Friday, June 30, 2017 at 7:49:12 AM UTC-7, Anh Vo wrote:
> On Friday, June 30, 2017 at 4:09:31 AM UTC-7, Lucretia wrote:
> > On Friday, 30 June 2017 09:49:59 UTC+1, bbab...@gmail.com  wrote:
> > > Hello everyone,
> > > 
> > > I tried to compile this 
> > > 
> > > procedure bug is
> > > 	type my_int is new integer;
> > > 	type access_function_my_int is access function (n : my_int) return my_int;
> > > 	function f (n : my_int) return my_int is (n);
> > > 	a : access_function_my_int :=f'access;
> > > begin
> > > 	null;
> > > end bug;
> > > 
> > > with the command line : gcc -c -gnat2012 bug.adb
> > > 
> > > and then I get this message from the compiler:
> > > 
> > > 
> > > raised STORAGE_ERROR : stack overflow or erroneous memory access
> > > 
> > > If I modify the type "my_int" by writing subtype my_int is integer;
> > > then I dont get any error from the compiler.
> > > 
> > > More interesting, if in the first program, the function f is no longer written inline, then I dont get any error.
> > > 
> > > Does anyone know what's happeing ?
> > 
> > You can't create a local pointer to f or anything there, you have to define it in a package. You're essentially trying to create a pointer on the stack to something else on the stack. There is a way around it, I think unchecked_conversion, not sure now.
> > 
> 
> The compiler should reject it if it does not compile with syntax rule. In this case, it does compile. In fact, if the function expression is replaced by normal function, it compiles fine. 
> 
> Therefore, a bug report should be sent to gnat@adacore.com.
> 
> Anh Vo

Correcting my typo - "it does compile" was meant "it does comply"

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

* Re: bug compiler ?
  2017-06-30  8:49 bug compiler ? bbaborum
  2017-06-30 11:09 ` Lucretia
@ 2017-06-30 15:11 ` AdaMagica
  2017-06-30 18:20   ` Randy Brukardt
  1 sibling, 1 reply; 10+ messages in thread
From: AdaMagica @ 2017-06-30 15:11 UTC (permalink / raw)


Just a guess: Maybe the compiler treats this simple statement function as having convention intrinsic. Intrinsic functions have no address and therefore no access is possible.
Whether this is legal - check the RM - I'm too lazy.


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

* Re: bug compiler ?
  2017-06-30 15:11 ` AdaMagica
@ 2017-06-30 18:20   ` Randy Brukardt
  0 siblings, 0 replies; 10+ messages in thread
From: Randy Brukardt @ 2017-06-30 18:20 UTC (permalink / raw)


"AdaMagica" <christ-usch.grein@t-online.de> wrote in message 
news:c47d5433-8eb5-4dde-99f9-173f7dded62c@googlegroups.com...
> Just a guess: Maybe the compiler treats this simple statement function as 
> having convention intrinsic. Intrinsic functions have no address and 
> therefore no access is possible.
> Whether this is legal - check the RM - I'm too lazy.

It's legal. Expression functions aren't Intrinsic, they're just a short-hand 
for a usual function call. So this should be fine, and it seems that 
whatever is going on is not fine, so it is a compiler bug.

                            Randy.


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

* Re: bug compiler ?
  2017-06-30 14:49   ` Anh Vo
  2017-06-30 15:03     ` Anh Vo
@ 2017-06-30 18:47     ` Simon Wright
  2017-06-30 19:42       ` Anh Vo
  2017-07-02 16:43       ` bbaborum
  1 sibling, 2 replies; 10+ messages in thread
From: Simon Wright @ 2017-06-30 18:47 UTC (permalink / raw)


Anh Vo <anhvofrcaus@gmail.com> writes:

> Therefore, a bug report should be sent to gnat@adacore.com.

report@adacore.com

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

* Re: bug compiler ?
  2017-06-30 18:47     ` Simon Wright
@ 2017-06-30 19:42       ` Anh Vo
  2017-07-02 16:43       ` bbaborum
  1 sibling, 0 replies; 10+ messages in thread
From: Anh Vo @ 2017-06-30 19:42 UTC (permalink / raw)


On Friday, June 30, 2017 at 11:47:24 AM UTC-7, Simon Wright wrote:
> Anh Vo <anhvofrcaus@gmail.com> writes:
> 
> > Therefore, a bug report should be sent to gnat@adacore.com.
> 
> report@adacore.com

Thanks Simon for your correction.


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

* Re: bug compiler ?
  2017-06-30 11:09 ` Lucretia
  2017-06-30 14:49   ` Anh Vo
@ 2017-07-02 16:42   ` bbaborum
  1 sibling, 0 replies; 10+ messages in thread
From: bbaborum @ 2017-07-02 16:42 UTC (permalink / raw)


Le vendredi 30 juin 2017 13:09:31 UTC+2, Lucretia a écrit :
> On Friday, 30 June 2017 09:49:59 UTC+1, bbab...@gmail.com  wrote:
> > Hello everyone,
> > 
> > I tried to compile this 
> > 
> > procedure bug is
> > 	type my_int is new integer;
> > 	type access_function_my_int is access function (n : my_int) return my_int;
> > 	function f (n : my_int) return my_int is (n);
> > 	a : access_function_my_int :=f'access;
> > begin
> > 	null;
> > end bug;
> > 
> > with the command line : gcc -c -gnat2012 bug.adb
> > 
> > and then I get this message from the compiler:
> > 
> > 
> > raised STORAGE_ERROR : stack overflow or erroneous memory access
> > 
> > If I modify the type "my_int" by writing subtype my_int is integer;
> > then I dont get any error from the compiler.
> > 
> > More interesting, if in the first program, the function f is no longer written inline, then I dont get any error.
> > 
> > Does anyone know what's happeing ?
> 
> You can't create a local pointer to f or anything there, you have to define it in a package. You're essentially trying to create a pointer on the stack to something else on the stack. There is a way around it, I think unchecked_conversion, not sure now.
> 
> Luke.

No.
My access function is perfectly legal in this case.
If it were a problem, the compiler would produce an error message. Instead it simply crashes.

You didn't read the end of my post.

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

* Re: bug compiler ?
  2017-06-30 18:47     ` Simon Wright
  2017-06-30 19:42       ` Anh Vo
@ 2017-07-02 16:43       ` bbaborum
  1 sibling, 0 replies; 10+ messages in thread
From: bbaborum @ 2017-07-02 16:43 UTC (permalink / raw)


Le vendredi 30 juin 2017 20:47:24 UTC+2, Simon Wright a écrit :
> Anh Vo <anhvofrcaus@gmail.com> writes:
> 
> > Therefore, a bug report should be sent to gnat@adacore.com.
> 
> report@adacore.com

Thank you.
I just reported it.

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

end of thread, other threads:[~2017-07-02 16:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-30  8:49 bug compiler ? bbaborum
2017-06-30 11:09 ` Lucretia
2017-06-30 14:49   ` Anh Vo
2017-06-30 15:03     ` Anh Vo
2017-06-30 18:47     ` Simon Wright
2017-06-30 19:42       ` Anh Vo
2017-07-02 16:43       ` bbaborum
2017-07-02 16:42   ` bbaborum
2017-06-30 15:11 ` AdaMagica
2017-06-30 18:20   ` Randy Brukardt

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