File: common_17.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (22 lines) | stat: -rw-r--r-- 778 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
! Test: COMMON block with type aliasing (same storage, different types)
! This tests storage association where the same bytes are viewed differently
program common_17
    implicit none
    double precision :: arr(4)  ! 32 bytes
    double precision :: original_value
    common /data/ arr
    arr(1) = 1.0d0
    original_value = arr(1)
    call sub_int_view()
    ! After sub_int_view modifies the first 4 bytes, arr(1) should be different
    if (arr(1) == original_value) error stop "Type aliasing failed - arr(1) unchanged"
    print *, "PASS: common_17"
end program

subroutine sub_int_view()
    implicit none
    integer :: iarr(8)  ! 32 bytes (different layout)
    common /data/ iarr
    ! Modify first integer (first 4 bytes of arr(1))
    iarr(1) = 999
end subroutine