public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant.
@ 2011-11-26 12:33 toon at moene dot org
2011-11-29 20:34 ` [Bug fortran/51310] " toon at moene dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: toon at moene dot org @ 2011-11-26 12:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
Bug #: 51310
Summary: -finit-bla doesn't initialize *all* items of type bla
to the requested constant.
Classification: Unclassified
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: toon@moene.org
The following source:
program nan
implicit none
real(8) :: joo(3)
joo(2) = 0
print *,joo
call sub(3)
end program nan
subroutine sub(n)
implicit none
integer, intent(in) :: n
real(8) :: a(n), var, b(3)
real(8), allocatable :: c(:)
!a(1) = 1
print *,'n=',n
print *,'a=',a
print *,'var=',var
print *,'b=',b
allocate(c(size(b)))
print *,'c=',c
a(1) = a(1) + 1
end subroutine sub
when compiled with gfortran -g -finit-real=snan outputs:
NaN 0.0000000000000000 NaN
n= 3
a= 0.0000000000000000 0.0000000000000000 0.0000000000000000
var= NaN
b= NaN NaN
NaN
c= 0.0000000000000000 0.0000000000000000 0.0000000000000000
Clearly, the allocatable c and the automatic array a are not initialized by the
compiler option.
1. Consider this an enhancement request - a colleague of mine was severely
hampered in his search for a bug.
2. Consider this a bug report with respect to our documentation, which doesn't
mention this exceptions at all.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant toon at moene dot org
@ 2011-11-29 20:34 ` toon at moene dot org
2011-12-05 18:17 ` toon at moene dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: toon at moene dot org @ 2011-11-29 20:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
--- Comment #1 from Toon Moene <toon at moene dot org> 2011-11-29 19:37:19 UTC ---
Created attachment 25948
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25948
Untested patch to the documentation
This is a completely untested patch to the documentation, as I cannot build gcc
trunk on Debian testing since August.
Perhaps someone else can review it as to:
- Correct texi syntax.
- Correct contents :-)
Thanks,
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant 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
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: toon at moene dot org @ 2011-12-05 18:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
Toon Moene <toon at moene dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #25948|0 |1
is obsolete| |
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2011-12-05
AssignedTo|unassigned at gcc dot |toon at moene dot org
|gnu.org |
Ever Confirmed|0 |1
--- Comment #2 from Toon Moene <toon at moene dot org> 2011-12-05 18:17:14 UTC ---
Created attachment 25996
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25996
A patch to the documentation that actually passes a build
I'll submit this patch to fortran@gcc.gnu.org for approval.
After that's done, and the patch is committed, I'll leave the bug report open
to see if I can fix some of the shortcomings.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant 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
2011-12-08 18:40 ` toon at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: toon at moene dot org @ 2011-12-05 20:04 UTC (permalink / raw)
To: gcc-bugs
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.").
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant toon at moene dot org
` (2 preceding siblings ...)
2011-12-05 20:04 ` toon at moene dot org
@ 2011-12-08 18:40 ` toon at gcc dot gnu.org
2011-12-08 21:01 ` toon at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: toon at gcc dot gnu.org @ 2011-12-08 18:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
--- Comment #4 from toon at gcc dot gnu.org 2011-12-08 18:38:39 UTC ---
Author: toon
Date: Thu Dec 8 18:38:32 2011
New Revision: 182127
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182127
Log:
2011-12-08 Toon Moene <toon@moene.org>
PR fortran/51310
* invoke.texi: Itemize the cases for which
-finit-<type>=<constant> doesn't work.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/invoke.texi
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant toon at moene dot org
` (3 preceding siblings ...)
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
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: toon at gcc dot gnu.org @ 2011-12-08 21:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
--- Comment #5 from toon at gcc dot gnu.org 2011-12-08 20:58:31 UTC ---
Author: toon
Date: Thu Dec 8 20:58:23 2011
New Revision: 182138
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182138
Log:
2011-12-08 Toon Moene <toon@moene.org>
PR fortran/51310
* invoke.texi: Itemize the cases for which
-finit-<type>=<constant> doesn't work.
Modified:
branches/gcc-4_6-branch/gcc/fortran/ChangeLog
branches/gcc-4_6-branch/gcc/fortran/invoke.texi
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant toon at moene dot org
` (4 preceding siblings ...)
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
7 siblings, 0 replies; 9+ messages in thread
From: toon at moene dot org @ 2011-12-08 21:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
Toon Moene <toon at moene dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
--- Comment #6 from Toon Moene <toon at moene dot org> 2011-12-08 21:01:06 UTC ---
The bugs in the documentation have been fixed, so now it is an enhancement to a
set of debugging compiler flags.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant toon at moene dot org
` (5 preceding siblings ...)
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
7 siblings, 0 replies; 9+ messages in thread
From: toon at gcc dot gnu.org @ 2011-12-15 18:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
--- Comment #7 from toon at gcc dot gnu.org 2011-12-15 18:26:08 UTC ---
Author: toon
Date: Thu Dec 15 18:26:02 2011
New Revision: 182384
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182384
Log:
2011-12-15 Toon Moene <toon@moene.org>
PR fortran/51310
* resolve.c (build_default_init_expr): Allow non-allocatable,
non-compile-time-constant-shape arrays to have a default
initializer.
* invoke.texi: Delete the restriction on automatic arrays not
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/invoke.texi
trunk/gcc/fortran/resolve.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51310] -finit-bla doesn't initialize *all* items of type bla to the requested constant.
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant toon at moene dot org
` (6 preceding siblings ...)
2011-12-15 18:35 ` toon at gcc dot gnu.org
@ 2011-12-22 20:18 ` toon at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: toon at gcc dot gnu.org @ 2011-12-22 20:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51310
--- Comment #8 from toon at gcc dot gnu.org 2011-12-22 19:23:31 UTC ---
Author: toon
Date: Thu Dec 22 19:23:26 2011
New Revision: 182634
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182634
Log:
2011-12-22 Toon Moene <toon@moene.org>
PR fortran/51310
* resolve.c (build_default_init_expr): Allow non-allocatable,
non-compile-time-constant-shape arrays to have a default
initializer.
* invoke.texi: Delete the restriction on automatic arrays not
being initialized by -finit-<type>=<constant>.
Modified:
branches/gcc-4_6-branch/gcc/fortran/ChangeLog
branches/gcc-4_6-branch/gcc/fortran/invoke.texi
branches/gcc-4_6-branch/gcc/fortran/resolve.c
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-12-22 19:24 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-26 12:33 [Bug fortran/51310] New: -finit-bla doesn't initialize *all* items of type bla to the requested constant 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
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
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).