This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/16208] gfortran internal error (assertion failed)
- From: "anlauf at hep dot tu-darmstadt dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Jun 2004 20:38:58 -0000
- Subject: [Bug fortran/16208] gfortran internal error (assertion failed)
- References: <20040625202558.16208.anlauf@hep.tu-darmstadt.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From anlauf at hep dot tu-darmstadt dot de 2004-06-25 20:38 -------
Somehow I can't manage to upload the file, so here it is (prime.f90)
module all_my_functions
implicit none
contains
function compute_primes(n, count)
integer, intent(in) :: n
integer, intent(out) :: count
integer, pointer :: compute_primes(:)
integer sieve_table(0:n/bit_size(1)+1)
integer i
integer upper
integer j
integer second_count
sieve_table = 0
sieve_table(0) = 3 ! 0 and 1 aren't prime
upper = sqrt(n+0.5d0)
do i = 2, upper
if(iand(sieve_table(i/bit_size(1)), &
ishft(1,modulo(i,bit_size(1)))) == 0) then
do j = i**2, n, i
sieve_table(j/bit_size(1)) = &
ior(sieve_table(j/bit_size(1)), &
ishft(1,modulo(j,bit_size(1))))
end do
end if
end do
count = 0
do i = 1, n
if(iand(sieve_table(i/bit_size(1)), &
ishft(1,modulo(i,bit_size(1)))) == 0) then
count = count+1
end if
end do
allocate(compute_primes(count))
second_count = 0
do i = 1, n
if(iand(sieve_table(i/bit_size(1)), &
ishft(1,modulo(i,bit_size(1)))) == 0) then
second_count = second_count+1
compute_primes(second_count) = i
end if
end do
end function compute_primes
end module all_my_functions
program main
use all_my_functions
implicit none
integer, pointer :: numbers(:) => NULL()
integer count
integer n
write(*,'(a)',advance='no') ' Enter the upper bound:> '
read(*,*) n
numbers => compute_primes(n,count)
write(*,*) 'Count = ', count
write(*,*) 'Numbers = ', numbers
deallocate(numbers)
nullify(numbers)
end program main
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16208