replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Access violation
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Access violation

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Thu Jan 03, 2013 8:16 am    Post subject: Access violation Reply with quote

Paul,

This compiles correctly, but gives an Access violation run time error in /CHECKMATE mode. It works fine in release mode.

Code:

subroutine xxx(i)
   integer, intent(in) :: i
   real a(5)
   forall(i=1:5) a(i) = i
   print *, a
   print *, i
end subroutine xxx

program anon
   call xxx(1)
end

_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl


Last edited by davidb on Fri Jan 04, 2013 6:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Fri Jan 04, 2013 8:45 am    Post subject: Reply with quote

I have logged this for investigation.

At first glance in looks like /CHECKMATE ought to provide a graceful runtime error report. For release mode, FTN95 cannot do anything about the logical programming error. Is this your expectation?
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Fri Jan 04, 2013 6:10 pm    Post subject: Reply with quote

Hello Paul. All the best for 2013 to you and the people at Silverfrost

I'm sorry, I haven't been clear.

The code above is valid Fortran 95 code. (I haven't made a programming error). In the standard it says that indices used in FORALL statements and constructs have the scope of the FORALL statement or construct only, and do not affect or inherit attributes from other variables in scope that happen to have the same name.

The Fortran Handbook, J Adams et.al. specifically describes the case I have coded above where the index i has the same name as a dummy argument with the INTENT(IN) attribute as legal code.

The BUG is that an "Access Violation" error occurs at run-time when I run the code compiled with /CHECKMATE.

The code compiles and runs correctly in release mode, as I would expect.

The problem is similar to the one on nesting a FORALL inside a DO loop in the other thread.

I don't know how you are handling FORALL index scope in your compiler. One way to do it is to internally pre-pend some "illegal" character (e.g. @) to the index names in FORALL statements so the above code looks like the following internally. This will work even for nested FORALLs (where the FORALL scope is shared in the nest). I assume you are doing something like this anyway, since the code works fine in release mode.

Code:

subroutine xxx(i)
   integer, intent(in) :: i
   real a(5)
   ! integer @i is reserved on the stack or held in a register
   forall(@i=1:5) a(@i) = @i
   print *, a
   print *, i
end subroutine xxx

program anon
   call xxx(1)
end

_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Fri Jan 04, 2013 7:11 pm    Post subject: Reply with quote

The reason why the code works OK in release mode is probably because the argument value 1 is passed as an address and this address is used for the forall index.

The access violation will be something to do with the runtime checking code that goes wrong in this situation, otherwise I would anticipate a graceful runtime error message.

Your suggestion to change the internal name of the index may well fix everything in this context.

I have not had chance to look at the explist which should reveal what is going wrong.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Fri Jan 04, 2013 7:53 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
The reason why the code works OK in release mode is probably because the argument value 1 is passed as an address and this address is used for the forall index.


No. I think you are using a separate address. The code prints i = 1 at the end of subroutine xxx (not 5 or 6), so the value at the address of the i argument isn't being changed.

Can I repeat, the code is valid, so there shouldn't be a run time error (graceful or otherwise) when compiled with /CHECKMATE.

Regards
David.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Sat Jan 05, 2013 8:07 am    Post subject: Reply with quote

Thanks. I did understand that there is no programming error.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Wed Mar 27, 2013 6:27 pm    Post subject: Reply with quote

I have fixed this bug for the next release (after 6.35).
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Wed Mar 27, 2013 6:46 pm    Post subject: Reply with quote

Thanks Paul.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group