public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/42267]  New: interaction between -finit-local-zero and -fno-automatic
@ 2009-12-03 19:14 bdavis at gcc dot gnu dot org
  2009-12-03 19:16 ` [Bug fortran/42267] " bdavis at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: bdavis at gcc dot gnu dot org @ 2009-12-03 19:14 UTC (permalink / raw)
  To: gcc-bugs

when using both flags, the variables are initialized on every function call. 
see the example below:


bash-3.2$ cat lvar.f 
       REAL A(100)
       PRINT*,'Expect them to be zero'
       CALL ONE
       PRINT*,'Expect them to be 1..10'
       CALL TWO
       PRINT*,'Expect them to be 1..10'
       CALL ONE
       END
       SUBROUTINE ONE
       REAL A(100)
       INTEGER I
       PRINT*,"Sub One Loc(a) is ",LOC(A)
       DO I=1,10
          PRINT*,A(I)
          A(I) = I
       END DO
       END
       SUBROUTINE TWO
       REAL A(100)
       INTEGER I
       PRINT*,"Sub Two Loc(a) is ",LOC(A)
       DO I = 1,10
         A(I) = 0
       END DO
       END
bash-3.2$ /usr/local/bin/gfortran -static lvar.f -finit-local-zero
-fno-automatic
bash-3.2$  /usr/local/bin/gfortran --version
GNU Fortran (GCC) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

bash-3.2$ ./a.out
 Expect them to be zero
 Sub One Loc(a) is    135144832
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
 Expect them to be 1..10
 Sub Two Loc(a) is    135144416
 Expect them to be 1..10
 Sub One Loc(a) is    135144832
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000    
   0.0000000


-- 
           Summary: interaction between -finit-local-zero and -fno-automatic
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bdavis at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/42267] interaction between -finit-local-zero and -fno-automatic
  2009-12-03 19:14 [Bug fortran/42267] New: interaction between -finit-local-zero and -fno-automatic bdavis at gcc dot gnu dot org
@ 2009-12-03 19:16 ` bdavis at gcc dot gnu dot org
  2009-12-03 20:06 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bdavis at gcc dot gnu dot org @ 2009-12-03 19:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bdavis at gcc dot gnu dot org  2009-12-03 19:16 -------
here is a patch against 4.4.1





diff --context --recursive gcc-4.4.1/gcc/fortran/gfortran.h
gcc-4.4.1_bud/gcc/fortran/gfortran.h
*** gcc-4.4.1/gcc/fortran/gfortran.h    2009-02-21 16:25:06.000000000 -0600
--- gcc-4.4.1_bud/gcc/fortran/gfortran.h        2009-12-03 09:24:11.000000000
-0600
***************
*** 2024,2029 ****
--- 2024,2030 ----
    int flag_init_character;
    char flag_init_character_value;
    int flag_align_commons;
+   int flag_no_automatic;

    int fpe;

diff --context --recursive gcc-4.4.1/gcc/fortran/options.c
gcc-4.4.1_bud/gcc/fortran/options.c
*** gcc-4.4.1/gcc/fortran/options.c     2008-11-03 01:20:24.000000000 -0600
--- gcc-4.4.1_bud/gcc/fortran/options.c 2009-12-03 09:24:54.000000000 -0600
***************
*** 346,352 ****

    /* Implement -fno-automatic as -fmax-stack-var-size=0.  */
    if (!gfc_option.flag_automatic)
!     gfc_option.flag_max_stack_var_size = 0;

    if (pedantic)
      { 
--- 346,355 ----

    /* Implement -fno-automatic as -fmax-stack-var-size=0.  */
    if (!gfc_option.flag_automatic)
!     {
!       gfc_option.flag_no_automatic = 1;
!       gfc_option.flag_max_stack_var_size = 0;
!     }

    if (pedantic)
      { 
diff --context --recursive gcc-4.4.1/gcc/fortran/resolve.c
gcc-4.4.1_bud/gcc/fortran/resolve.c
*** gcc-4.4.1/gcc/fortran/resolve.c     2009-06-20 04:21:06.000000000 -0500
--- gcc-4.4.1_bud/gcc/fortran/resolve.c 2009-12-03 09:49:52.000000000 -0600
***************
*** 7486,7492 ****

    /* For saved variables, we don't want to add an initializer at 
       function entry, so we just add a static initializer.  */
!   if (sym->attr.save || sym->ns->save_all)
      {
        /* Don't clobber an existing initializer!  */
        gcc_assert (sym->value == NULL);
--- 7486,7492 ----

    /* For saved variables, we don't want to add an initializer at 
       function entry, so we just add a static initializer.  */
!   if (sym->attr.save || sym->ns->save_all || gfc_option.flag_no_automatic )
      {
        /* Don't clobber an existing initializer!  */
        gcc_assert (sym->value == NULL);


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/42267] interaction between -finit-local-zero and -fno-automatic
  2009-12-03 19:14 [Bug fortran/42267] New: interaction between -finit-local-zero and -fno-automatic bdavis at gcc dot gnu dot org
  2009-12-03 19:16 ` [Bug fortran/42267] " bdavis at gcc dot gnu dot org
@ 2009-12-03 20:06 ` burnus at gcc dot gnu dot org
  2009-12-03 20:21 ` bdavis at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-12-03 20:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2009-12-03 20:06 -------
That's already fixed for 4.5.0, see PR 41860. Do you think it makes sense to
backport the patch to 4.4.x? (Note: 4.5.0 is currently in Stage4 (regression
fixes only) - thus the question is how many fixed 4.4.x would be used.)


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org
      Known to fail|                            |4.3.4 4.4.2
      Known to work|                            |4.5.0


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/42267] interaction between -finit-local-zero and -fno-automatic
  2009-12-03 19:14 [Bug fortran/42267] New: interaction between -finit-local-zero and -fno-automatic bdavis at gcc dot gnu dot org
  2009-12-03 19:16 ` [Bug fortran/42267] " bdavis at gcc dot gnu dot org
  2009-12-03 20:06 ` burnus at gcc dot gnu dot org
@ 2009-12-03 20:21 ` bdavis at gcc dot gnu dot org
  2009-12-03 20:47 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bdavis at gcc dot gnu dot org @ 2009-12-03 20:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bdavis at gcc dot gnu dot org  2009-12-03 20:21 -------
silly me.  glad to see we both fixed it the same way :)

close with no more action taken ?


--bud


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/42267] interaction between -finit-local-zero and -fno-automatic
  2009-12-03 19:14 [Bug fortran/42267] New: interaction between -finit-local-zero and -fno-automatic bdavis at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-12-03 20:21 ` bdavis at gcc dot gnu dot org
@ 2009-12-03 20:47 ` burnus at gcc dot gnu dot org
  2009-12-03 21:14 ` rguenth at gcc dot gnu dot org
  2009-12-03 21:19 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-12-03 20:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2009-12-03 20:47 -------
(In reply to comment #3)
> silly me.  glad to see we both fixed it the same way :)
> close with no more action taken ?

I am fine with closing it as won't fix, but one could also mark it as
duplicate. (Or backport the fix and keep it open.)


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/42267] interaction between -finit-local-zero and -fno-automatic
  2009-12-03 19:14 [Bug fortran/42267] New: interaction between -finit-local-zero and -fno-automatic bdavis at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-12-03 20:47 ` burnus at gcc dot gnu dot org
@ 2009-12-03 21:14 ` rguenth at gcc dot gnu dot org
  2009-12-03 21:19 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-12-03 21:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2009-12-03 21:14 -------
If it's not a regression close it as fixed in 4.5.


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/42267] interaction between -finit-local-zero and -fno-automatic
  2009-12-03 19:14 [Bug fortran/42267] New: interaction between -finit-local-zero and -fno-automatic bdavis at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-12-03 21:14 ` rguenth at gcc dot gnu dot org
@ 2009-12-03 21:19 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-12-03 21:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2009-12-03 21:19 -------


*** This bug has been marked as a duplicate of 41860 ***


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-12-03 21:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-03 19:14 [Bug fortran/42267] New: interaction between -finit-local-zero and -fno-automatic bdavis at gcc dot gnu dot org
2009-12-03 19:16 ` [Bug fortran/42267] " bdavis at gcc dot gnu dot org
2009-12-03 20:06 ` burnus at gcc dot gnu dot org
2009-12-03 20:21 ` bdavis at gcc dot gnu dot org
2009-12-03 20:47 ` burnus at gcc dot gnu dot org
2009-12-03 21:14 ` rguenth at gcc dot gnu dot org
2009-12-03 21:19 ` burnus at gcc dot gnu dot 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).