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 -> General
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2923
Location: South Pole, Antarctica

PostPosted: Thu Aug 16, 2012 10:18 am    Post subject: Access Violation Reply with quote

It is hell and disaster when you try to use not your own code written in different compiler...And the total shutdown is when you get this scary system "access violation" after which you search exit in total darkness...

In very short demo code, the variable is defined and used like here

Code:
   module M_matdim
   integer,  save :: iab = 0
   end module M_matdim

!....................................

   program test
   call sub1
   end program

!....................................
   subroutine sub1
   use M_matdim,only : iab
   iab = 0
   end subroutine


The code stops at the line
iab=0
If i add some lines before this line the code still stops with access violation on iab=0.

Feel myself helpless when such errors occur...

I use /full_debug /check /undef
What you'd suggest to look at? Any switches to add ?

Authors mention they see the same error with IFORT compiler with some options "-m64 -i8" AND some routines were compiled with flag "-g" and others "without". Means code hidden error somewhere?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Thu Aug 16, 2012 1:53 pm    Post subject: Reply with quote

Dan,

I'm not sure what the problem is, but there are some unusual codings in this example:
Why use SAVE in a module ?
Why select ONLY when there is only one element in the module ?
I'm not sure if these are illegal but they look odd to me

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Aug 16, 2012 2:19 pm    Post subject: Reply with quote

Runs OK for me under 32bit XP. Are you using the latest FTN95? What operating system?
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2402
Location: Yateley, Hants, UK

PostPosted: Thu Aug 16, 2012 2:33 pm    Post subject: Reply with quote

Dratted Fortran 90 stuff that old timers like me cannot read ....

Isn't iab effectively a parameter, and its value cannot (should not) be changed? Might have been clearer with:

Code:
integer, parameter :: iab = 0


presumably compiler assumes it to be a parameter because of the initial value assignment, and only enforces no reassignment rule with those fancy switches. (Paul ?) Does save make it a parameter with the other compiler?

Runs OK for me too (Windows 7 32 bit) with no compiler switches.

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2923
Location: South Pole, Antarctica

PostPosted: Thu Aug 16, 2012 3:02 pm    Post subject: Reply with quote

The snippet above of course works fine. That example was just an illustration with a lot of real coding omitted. The full code makes something with this line so that access violation is happening. May be turning it into parameter at run time because at compile time FTN95 easily detects syntax violation and does not produce executable....

There is a lot of actual stuff in the module, so ONLY uses only this and couple more elements (also omitted for simplicity). Also, I removed temporally SAVE but that gave no change.

Yes, the language became more complex. In older Fortran77 that would probably not happen at all...
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2402
Location: Yateley, Hants, UK

PostPosted: Thu Aug 16, 2012 3:52 pm    Post subject: Reply with quote

Dan,

If iab was a PARAMETER in Fortran 77 it should produce an error - and does in FTN95 when running on Fortran 77 code:

Code:
      PROGRAM M
      INTEGER IAB
      PARAMETER (IAB=0)
      IAB = 10
      END



The error on line 4 is "Constant found on left hand side of an expression where variable expected", and so program won't compile. Wrapping things up in modules just makes the errors more difficult to detect - it's an access violation in the code you posted because you aren't supposed to change the values of constants - even if it is from 0 to 0.

This stops with the same error:

Code:
      INTEGER, PARAMETER :: IAB=0


But if you replace PARAMETER with SAVE (or leave it off) you get a warning that "Variable IAB has been given a value but never used". Perhaps it is assumed to be a parameter if defined in a Module in FTN95?

Eddie
Back to top
View user's profile Send private message
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Thu Aug 16, 2012 4:45 pm    Post subject: Re: Reply with quote

LitusSaxonicum wrote:

Isn't iab effectively a parameter, and its value cannot (should not) be changed? Might have been clearer with:

Code:
integer, parameter :: iab = 0


presumably compiler assumes it to be a parameter because of the initial value assignment, and only enforces no reassignment rule with those fancy switches. (Paul ?) Does save make it a parameter with the other compiler?


Save attribute just makes variable static, not constant. When variable is declared in the module, it probably just acts like global variable to those procedures using it.

In Fortran 90, a local variable that is initialized when declared has an implicit save attribute.

Code:

! these two declarations are the same
integer :: i = 10
integer, save :: i = 10
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2402
Location: Yateley, Hants, UK

PostPosted: Thu Aug 16, 2012 5:29 pm    Post subject: Reply with quote

Jalih,

The question is not what the compiler should do, but what it does do.

I consider most of the changes introduced in recent Fortran definitions to be a sort of devilry, so expect them to cause hell!

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2923
Location: South Pole, Antarctica

PostPosted: Thu Aug 16, 2012 11:14 pm    Post subject: Reply with quote

For catching such bugs FTN95 has to introduce one more compiler option -- /enforce -- to enforce the most strict rules on everything.

Also does access violation have different flavors to get more information what specifically is violated?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Aug 17, 2012 7:35 am    Post subject: Reply with quote

Have you tried /ISO.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2923
Location: South Pole, Antarctica

PostPosted: Fri Aug 17, 2012 10:29 am    Post subject: Reply with quote

Will check because the exact reason for access violation and its specifics are still unknown but what caused it now clear - some module was absent. Unclear why this gave scary Access Violation which killed several my days and your, guys, time, instead of missing subroutine warning. Thanks for discussion and suggestions
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 -> General 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