replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - /full_undef problem
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 

/full_undef problem

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



Joined: 14 Nov 2007
Posts: 314
Location: D�sseldorf, Germany

PostPosted: Mon Oct 06, 2014 4:33 pm    Post subject: /full_undef problem Reply with quote

I tried to use the /full_undef compiler option and got a problem which might only be a problem of understanding. Can anyone please help? Here is a small example of code. I want to save the image palette rgb_a in another palette rgb_b. Without /full_undef everything runs prefectly, but using this option and then starting the program, an error occurs ("Reference to undefined character", line 27 - the third line from below). But both palettes ARE defined (??)

Code:
      winapp
      program test
      implicit none

      integer*4     i
      character*1   rgb_a(3,0:255),rgb_b(3,0:255)

      do i = 0,255
        rgb_a(1,i) = char(i)
        rgb_a(2,i) = char(i)
        rgb_a(3,i) = char(i)
      end do

      call save_pal(rgb_a,rgb_b)

      do i = 0,255
        print*,i,' ',rgb_b(1,i)
      end do
      end

      subroutine save_pal(rgb_a,rgb_b)

      implicit none

      character*1   rgb_a(3,0:255),rgb_b(3,0:255)

      rgb_b = rgb_a
      return
      end

Thanks in advance
Wilfried
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Oct 06, 2014 7:23 pm    Post subject: Reply with quote

This looks like a bug. In the line "rgb_b = rgb_a", copying only gets up to 128 on the second index. Probably something to do with signed/unsigned values in the checking of character values.

In the short term you may have to avoid /full_undef. You could do this in this local context now that you are sure that all values are being copied correctly.
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: Mon Jan 19, 2015 2:40 pm    Post subject: Reply with quote

It turns out that this is not a bug.

The FULL_UNDEF feature has to use a character value to represent the undefined state and this happens to be 128 which is assumed to be out of range in normal usage. This means that if you assign a character to char(128) and then copy it to another character (when applying /FULL_UNDEF) then you will get the failure.
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1899

PostPosted: Mon Jan 19, 2015 4:03 pm    Post subject: Reply with quote

A similar problem could occur with INTEGER and other variable types, since a specific value is used to represent "undefined", but the frequency of such false positives is far smaller than in the character variable case. In general, any code that references a variable that can be set to the entire range of possible values of a specific type will yield a false positive when /FULL_UNDEF is used.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Jan 20, 2015 10:29 am    Post subject: Reply with quote

Specifically INTEGER and CHARACTER variables can generate false positives with INTEGER*1 and CHARACTER*1 being the worst cases (1 in 256).

REAL, COMPLEX and LOGICAL values should not generate false positives in normal usage.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Tue Jan 20, 2015 11:21 pm    Post subject: Reply with quote

I assume with LOGICAL you have "spare" bits in which to encode the undefined/defined status. You only really need 1 bit to code .TRUE. or .FALSE. IF so false positives should be impossible in such variables.

The bit patterns used for real and complex values never seem to show up in my models so I have never had a false positive due to chance.
_________________
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