public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order
@ 2011-06-30  6:53 burnus at gcc dot gnu.org
  2011-06-30  7:01 ` [Bug fortran/49586] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-06-30  6:53 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Multiple initialization with DATA: Warning and
                    initialization order
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
        Depends on: 49540


Follow up to PR 49540.

gfortran - as some other compilers - allows multiple initialization in DATA
statements.

Expected:
- Warn - at least with -Wall - if multiple initialization occur
  (Currently, only -pedantic warns and -std=f* prints an error)
- Check whether the current initialization makes sense
  I think the version of gfortran 4.1 + the commercial compilers makes most
  sense.


For the test case below, the result is (* = warns by default):

- g95, NAG: Error because of multiple initialization

- gfortran 4.1 (!), ifort, sunf90, pathf90*, openf90*, pgf90:
4, 5, 5, 5, 5,  5, 5, 5, 5, 5,  5, 5, 5, 5, 5,  5, 5, 5, 5, 5,  5, 5, 5, 5, 6

- gfortran 4.6 and 4.7:
4, 5, 5, 5, 5,  1, 2, 2, 2, 3,  5, 5, 5, 5, 5,  5, 5, 5, 5, 5,  5, 5, 5, 5, 6

- gfortran 4.3, 4.4 and 4.5:
4, 3, 3, 3, 3,  3, 3, 3, 3, 3,  3, 3, 3, 3, 3,  3, 3, 3, 3, 3,  3, 3, 3, 3, 6


      program pr49540_2
        common /a/ i(5,5)
        data i(1:5,2) /1, 3 * 2, 3/
        data i /4, 23 * 5, 6/
        print '(5(5(i0:", "):" "))', i
      end


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
@ 2011-06-30  7:01 ` jakub at gcc dot gnu.org
  2011-06-30 11:43 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-30  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-30 07:01:01 UTC ---
More complete testcase, which should be adjusted to do runtime checking of the
variable content based on what we decide, and add whatever options will be
needed to disable the errors when compiling it.

block data
  common /a/ i(5,5)
  data i /4, 23 * 5, 6/
  data i(:,2) /1, 3 * 2, 3/
  common /b/ j(5,5)
  data j(2,:) /1, 3 * 2, 3/
  data j /4, 23 * 5, 6/
  common /c/ k(5,5)
  data k(:,2) /1, 3 * 2, 3/
  data k /4, 23 * 5, 6/
  common /d/ l(5,5)
  data l /4, 23 * 5, 6/
  data l(2,:) /1, 3 * 2, 3/
end block data


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
  2011-06-30  7:01 ` [Bug fortran/49586] " jakub at gcc dot gnu.org
@ 2011-06-30 11:43 ` jakub at gcc dot gnu.org
  2011-06-30 12:31 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-30 11:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-30 11:43:24 UTC ---
The order apparently changed with
http://gcc.gnu.org/viewcvs?view=revision&revision=114406
which doesn't change the order actually, but only wouldn't overwrite anything.
So, even back then the DATA stmts used to be traversed in wrong order.


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
  2011-06-30  7:01 ` [Bug fortran/49586] " jakub at gcc dot gnu.org
  2011-06-30 11:43 ` jakub at gcc dot gnu.org
@ 2011-06-30 12:31 ` jakub at gcc dot gnu.org
  2011-06-30 13:58 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-30 12:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-30 12:30:51 UTC ---
Created attachment 24645
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24645
gcc47-pr49586.patch

Untested fix for the order.


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-06-30 12:31 ` jakub at gcc dot gnu.org
@ 2011-06-30 13:58 ` burnus at gcc dot gnu.org
  2011-06-30 16:11 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-06-30 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-06-30 13:57:21 UTC ---
(In reply to comment #3)
> Untested fix for the order.

For the example of comment 0, gfortran + patch gives the gfortran 4.1 et al.
result.

For the example which is contained in the attachment, one gets the following
result, when printing (in that order) i, j, k, l.

gfortran 4.1-4.5: ICE in gfc_assign_data_value_range.

gfortran 4.7 (w/ patch) -- and pathf90 3.2.99, openf95 4.2 and sunf95 8.3:
4, 5, 5, 5, 5, 1, 2, 2, 2, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 1, 5, 5, 5, 5, 2, 5, 5, 5, 5, 2, 5, 5, 5, 5, 2, 5, 5, 5, 5, 3, 5, 5, 6

ifort 11.1 and pgf90 10.1:
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 6
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6

gfortran 4.6/4.7 (w/o patch):
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 1, 5, 5, 5, 5, 2, 5, 5, 5, 5, 2, 5, 5, 5, 5, 2, 5, 5, 5, 5, 3, 5, 5, 6
4, 5, 5, 5, 5, 1, 2, 2, 2, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6

For comparison, the m and n lines are:
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6
4, 5, 5, 5, 5, 1, 2, 2, 2, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-06-30 13:58 ` burnus at gcc dot gnu.org
@ 2011-06-30 16:11 ` jakub at gcc dot gnu.org
  2011-06-30 17:29 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-30 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-30 16:10:18 UTC ---
Unfortunately, this patch breaks gfortran.fortran-torture/execute/data.f90
compilation, it fails with a cryptic error.
No idea if it is a bug in the testcase that just relied on the older ordering,
or if my patch is buggy.  I guess I give up here.


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-06-30 16:11 ` jakub at gcc dot gnu.org
@ 2011-06-30 17:29 ` dominiq at lps dot ens.fr
  2013-06-16 18:15 ` dominiq at lps dot ens.fr
  2013-06-16 18:15 ` dominiq at lps dot ens.fr
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-06-30 17:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-06-30 17:28:48 UTC ---
> Unfortunately, this patch breaks gfortran.fortran-torture/execute/data.f90
> compilation, it fails with a cryptic error.

Confirmed. A reduced test is

        ! Program to test data statement
        program data
        call sub1()
        end
        subroutine sub1()
        integer i
        type tmp
          integer, dimension(4)::a 
          real :: r 
        end type
        type tmp1
          type (tmp) t1(4)
          integer b
        end type
        type (tmp1) tmp2(2)
        ! Full array and scalar component initializer
        data tmp2(2)%t1(2)%r, tmp2(1)%t1(3)%a,
tmp2(1)%b/220,136,137,138,139,10/
        data tmp2(2)%t1(2)%a(3), tmp2(2)%t1(2)%a(1)/223,221/

        end

The error is emitted in show_loci in gcc/fortran/error.c when
l1 == NULL || l1->lb == NULL

With gdb I get

Breakpoint 1, show_loci (l1=0x141d23260, l2=0x0) at
../../work/gcc/fortran/error.c:383
383      if (l1 == NULL || l1->lb == NULL)
(gdb) p l1
$1 = (locus *) 0x141d23260
(gdb) p *l1
$2 = {
  nextc = 0x0, 
  lb = 0x0
}
(gdb) bt
#0  show_loci (l1=0x141d23260, l2=0x0) at ../../work/gcc/fortran/error.c:383
#1  0x000000010002832d in error_print (type=0x100a46df1 "Error:",
format0=0x100a63ad0 "non-constant initialization expression at %L",
argp=0x7fff5fbfd128) at ../../work/gcc/fortran/error.c:627
Previous frame inner to this frame (gdb could not unwind past this frame)


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-06-30 17:29 ` dominiq at lps dot ens.fr
@ 2013-06-16 18:15 ` dominiq at lps dot ens.fr
  2013-06-16 18:15 ` dominiq at lps dot ens.fr
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-16 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

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

--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Duplicate of pr45288.

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


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

* [Bug fortran/49586] Multiple initialization with DATA: Warning and initialization order
  2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-06-16 18:15 ` dominiq at lps dot ens.fr
@ 2013-06-16 18:15 ` dominiq at lps dot ens.fr
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-16 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

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

--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Duplicate of pr45288.

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

--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Duplicate of pr45288.

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


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

end of thread, other threads:[~2013-06-16 18:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30  6:53 [Bug fortran/49586] New: Multiple initialization with DATA: Warning and initialization order burnus at gcc dot gnu.org
2011-06-30  7:01 ` [Bug fortran/49586] " jakub at gcc dot gnu.org
2011-06-30 11:43 ` jakub at gcc dot gnu.org
2011-06-30 12:31 ` jakub at gcc dot gnu.org
2011-06-30 13:58 ` burnus at gcc dot gnu.org
2011-06-30 16:11 ` jakub at gcc dot gnu.org
2011-06-30 17:29 ` dominiq at lps dot ens.fr
2013-06-16 18:15 ` dominiq at lps dot ens.fr
2013-06-16 18:15 ` dominiq at lps dot ens.fr

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