This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310

--- Comment #3 from Toon Moene <toon at moene dot org> 2011-12-05 20:04:21 UTC ---
At first I thought that gfortran would initialize small local arrays to
whatever -finit-real indicated by making them static, instead of stack based.

However, perusing the assembler output of

      subroutine sub
      real a(3)
      print*,a
      end

(as a diff between gfortran -S and gfortran -S -finit-real=snan):

17c17,27
<     movq    $.LC0, -536(%rbp)
---
> 	movl	$1, %eax
> .L3:
> 	cmpq	$3, %rax
> 	jg	.L2
> 	leaq	-1(%rax), %rdx
> 	movl	$0x7fa00000, %ecx
> 	movl	%ecx, -16(%rbp,%rdx,4)
> 	addq	$1, %rax
> 	jmp	.L3
> .L2:

and checking with a small main program

      call sub
      end

that the output is really different:

$ ./a.out
  1.12103877E-44   0.0000000      9.80908925E-45

vs:

$ ./a.out
             NaN             NaN             NaN

convinced me otherwise.

So one wonders why that doesn't work with variable length automatic arrays (or
why it would even be hard to initialize malloc'd automatic arrays /
allocatables).

This quest to be continued ("do you think coconuts migrate ?  No - but they
could be carried.").


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