This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARGH. Who wrote intrinsic_set_exponent.f90?


On Mon, Aug 28, 2006 at 12:31:06PM -0700, DeLisle, Jerry V wrote:
> I am curious.  Would this be legal, aka standard conforming?
> 
> subroutine test_real4()
>   real x,y
>   integer i,n
>   equivalence(x,i)
>   x = 1.0   ! <-- Set this to some dummy value so that x is defined.
>   n = 128
>   i = o'00037777777' ! <-- This doesn't do what you think.
>   y = set_exponent (x, n) ! <-- This is nonconforming.
>   if (exponent (y) .ne. n) call abort()
> end subroutine 
> 

No.  The assignment to i causes i to become defined and
x becomes undefined.

Read these sections. 

14.7.5 Events that cause variables to become defined
14.7.6 Events that cause variables to become undefined

  Variables become undefined as follows:
      (1)   When a variable of a given type becomes defined, all
            associated variables of different type become undefined.

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]