From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68736 invoked by alias); 21 Oct 2015 10:32:01 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 68644 invoked by uid 48); 21 Oct 2015 10:31:58 -0000 From: "jb at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55207] [F08] Variables declared in the main program should implicitly get the SAVE attribute Date: Wed, 21 Oct 2015 10:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.8.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jb at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: janus at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg01723.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55207 Janne Blomqvist changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jb at gcc dot gnu.org --- Comment #19 from Janne Blomqvist --- As was mentioned recently on comp.lang.fortran, this affects OpenMP. Consider program teste_paralelo use omp_lib real :: v1(12,60,60,60,2) !$omp parallel do do kk=2,60 v1(5,2,2,kk,1)=0 enddo !$omp end parallel do !$omp parallel print *, 'Hello World!' !$omp end parallel end program teste_paralelo Compiling without OpenMP and checking the binary with size, the array v1 is allocated statically in the bss section: $ gfortran -g teste_paralelo.f90 -o test-serial $ size test-serial text data bss dec hex filename 2147 608 20736032 20738787 13c72e3 test-serial Enabling openmp, the array suddenly goes on the stack: $ gfortran -g -fopenmp teste_paralelo.f90 -o test $ size test text data bss dec hex filename 2822 656 8 3486 d9e test If one manually makes v1 saved, it naturally goes into the bss with openmp too: $ gfortran -g -fopenmp teste_paralelo.f90 -o test-save $ size test-save text data bss dec hex filename 2790 656 20736032 20739478 13c7596 test-save