public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "toon at moene dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
Date: Mon, 05 Dec 2011 20:04:00 -0000	[thread overview]
Message-ID: <bug-51310-4-vp7JL1NiOE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51310-4@http.gcc.gnu.org/bugzilla/>

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.").


  parent reply	other threads:[~2011-12-05 20:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-26 12:33 [Bug fortran/51310] New: " toon at moene dot org
2011-11-29 20:34 ` [Bug fortran/51310] " toon at moene dot org
2011-12-05 18:17 ` toon at moene dot org
2011-12-05 20:04 ` toon at moene dot org [this message]
2011-12-08 18:40 ` toon at gcc dot gnu.org
2011-12-08 21:01 ` toon at gcc dot gnu.org
2011-12-08 21:02 ` toon at moene dot org
2011-12-15 18:35 ` toon at gcc dot gnu.org
2011-12-22 20:18 ` toon at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-51310-4-vp7JL1NiOE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).