public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/29371]  New: Coredump when using -fbounds-check with pointer & nullify
@ 2006-10-06 14:29 tobias dot burnus at physik dot fu-berlin dot de
  2006-10-07 21:23 ` [Bug fortran/29371] " pault at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-10-06 14:29 UTC (permalink / raw)
  To: gcc-bugs

The following program coredumps at nullify() when compiled with -fbounds-check,
otherwise it does work as supposed. If I remove one of the nullify()s or remove
the loop, it works ok.

---------------------------------------------
program test
  implicit none
  type projector_t
    real,   pointer :: ket(:, :), bra(:, :)
  end type projector_t

  type(projector_t),pointer, dimension(:) :: p
  integer :: stat,i
  allocate(p(2),stat=stat)
  print *, 'state = ',stat
  do i = 1, 2
        nullify(p(i)%bra)
        nullify(p(i)%ket)
  end do
end program
---------------------------------------------


-- 
           Summary: Coredump when using -fbounds-check with pointer &
                    nullify
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot burnus at physik dot fu-berlin dot de


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


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

* [Bug fortran/29371] Coredump when using -fbounds-check with pointer & nullify
  2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
@ 2006-10-07 21:23 ` pault at gcc dot gnu dot org
  2006-10-07 21:24 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-10-07 21:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pault at gcc dot gnu dot org  2006-10-07 21:23 -------
Created an attachment (id=12395)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12395&action=view)
A provisional fix for this PR

This comes about because the gfc_evaluate_now is fixing the expression after it
has already been used.  The better thing to do, as in this patch, is to retain
the original expression and to make a new variable for the fixed value.

The only thing that is giving me pause is that this fix does not go far enough.
 I note that gfc_trans_array_bound_check does exactly the same thing. The 
  index = gfc_evaluate_now (index, &se->pre);
on line 1838  is either unnecessary, or else the l-value should not be index. 
I will check this out tomorrow morning.


-- 


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


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

* [Bug fortran/29371] Coredump when using -fbounds-check with pointer & nullify
  2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
  2006-10-07 21:23 ` [Bug fortran/29371] " pault at gcc dot gnu dot org
@ 2006-10-07 21:24 ` pault at gcc dot gnu dot org
  2006-10-11 20:43 ` pault at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-10-07 21:24 UTC (permalink / raw)
  To: gcc-bugs



-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-10-07 21:24:07
               date|                            |


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


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

* [Bug fortran/29371] Coredump when using -fbounds-check with pointer & nullify
  2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
  2006-10-07 21:23 ` [Bug fortran/29371] " pault at gcc dot gnu dot org
  2006-10-07 21:24 ` pault at gcc dot gnu dot org
@ 2006-10-11 20:43 ` pault at gcc dot gnu dot org
  2006-10-12  0:15 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-10-11 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pault at gcc dot gnu dot org  2006-10-11 20:43 -------
Created an attachment (id=12412)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12412&action=view)
The correct fix for this PR

THis turns out to be completely specific to nullify, or to a pointer assign to
NULL().  Looking at the code for pointer assignment, we immediately see that
the descriptor data set is being added to the block, FOLLOWED by the pre and
post blocks.  Since -fbounds-check fixes the value of the index in the pre
block, the net result is an index that is used before it is set.  The fix adds
the data set to the pre block, thereby putting things in the right order.

I'll just regtest this and then submit it.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #12395|0                           |1
        is obsolete|                            |


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


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

* [Bug fortran/29371] Coredump when using -fbounds-check with pointer & nullify
  2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
                   ` (2 preceding siblings ...)
  2006-10-11 20:43 ` pault at gcc dot gnu dot org
@ 2006-10-12  0:15 ` patchapp at dberlin dot org
  2006-10-14 13:10 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: patchapp at dberlin dot org @ 2006-10-12  0:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from patchapp at dberlin dot org  2006-10-12 00:15 -------
Subject: Bug number PR29371

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00635.html


-- 


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


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

* [Bug fortran/29371] Coredump when using -fbounds-check with pointer & nullify
  2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
                   ` (3 preceding siblings ...)
  2006-10-12  0:15 ` patchapp at dberlin dot org
@ 2006-10-14 13:10 ` pault at gcc dot gnu dot org
  2006-10-14 13:19 ` pault at gcc dot gnu dot org
  2006-11-10 21:53 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-10-14 13:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2006-10-14 13:10 -------
Subject: Bug 29371

Author: pault
Date: Sat Oct 14 13:09:56 2006
New Revision: 117732

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117732
Log:
2006-10-14 Paul Thomas <pault@gcc.gnu.org>

        PR fortran/29371
        * trans-expr.c (gfc_trans_pointer_assignment): Add the expression
        for the assignment of null to the data field to se->pre, rather
        than block.     

2006-10-14 Paul Thomas <pault@gcc.gnu.org>

        PR fortran/29371
        * gfortran.dg/nullify_3.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/nullify_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/29371] Coredump when using -fbounds-check with pointer & nullify
  2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
                   ` (4 preceding siblings ...)
  2006-10-14 13:10 ` pault at gcc dot gnu dot org
@ 2006-10-14 13:19 ` pault at gcc dot gnu dot org
  2006-11-10 21:53 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-10-14 13:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2006-10-14 13:19 -------
Fixed on trunk

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug fortran/29371] Coredump when using -fbounds-check with pointer & nullify
  2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
                   ` (5 preceding siblings ...)
  2006-10-14 13:19 ` pault at gcc dot gnu dot org
@ 2006-11-10 21:53 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-11-10 21:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2006-11-10 21:52 -------
Subject: Bug 29371

Author: pault
Date: Fri Nov 10 21:52:00 2006
New Revision: 118666

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118666
Log:
2006-11-10 Paul Thomas <pault@gcc.gnu.org>

        Backport from mainline.

        PR fortran/29371
        * trans-expr.c (gfc_trans_pointer_assignment): Add the expression
        for the assignment of null to the data field to se->pre, rather
        than block.

        PR fortran/29392
        * data.c (create_character_intializer): Copy and simplify
        the expressions for the start and end of a sub-string
        reference.

        PR fortran/29216
        PR fortran/29314
        * gfortran.h : Add EXEC_INIT_ASSIGN.
        * dump-parse-tree.c (gfc_show_code_node): The same.
        * trans-expr.c (gfc_trans_init_assign): New function.
        * trans-stmt.h : Add prototype for gfc_trans_init_assign.
        * trans.c (gfc_trans_code): Implement EXEC_INIT_ASSIGN.
        * resolve.c (resolve_allocate_exp): Replace EXEC_ASSIGN by
        EXEC_INIT_ASSIGN.
        (resolve_code): EXEC_INIT_ASSIGN does not need resolution.
        (apply_default_init): New function.
        (resolve_symbol): Call it for derived types that become
        defined but which do not already have an initialization
        expression..
        * st.c (gfc_free_statement): Include EXEC_INIT_ASSIGN.

        PR fortran/29387
        * trans-intrinsic.c (gfc_conv_intrinsic_len): Rearrange to have
        a specific case for EXPR_VARIABLE and, in default, build an ss
        to call gfc_conv_expr_descriptor for array expressions..

        PR fortran/29490
        * trans-expr.c (gfc_set_interface_mapping_bounds): In the case
        that GFC_TYPE_ARRAY_LBOUND is not available, use descriptor
        values for it and GFC_TYPE_ARRAY_UBOUND.

        PR fortran/29641
        * trans-types.c (gfc_get_derived_type): If the derived type
        namespace has neither a parent nor a proc_name, set NULL for
        the search namespace.

        PR fortran/24518
        * trans-intrinsic.c (gfc_conv_intrinsic_mod): Use built_in fmod
        for both MOD and MODULO, if it is available.

        PR fortran/29565
        * trans-expr.c (gfc_conv_aliased_arg): For an INTENT(OUT), save
        the declarations from the unused loops by merging the block
        scope for each; this ensures that the temporary is declared.

2006-11-10 Paul Thomas <pault@gcc.gnu.org>

        PR fortran/29371
        * gfortran.dg/nullify_3.f90: New test.

        PR fortran/29392
        * gfortran.dg/data_char_3.f90: New test.

        PR fortran/29216
        * gfortran.dg/result_default_init_1.f90: New test.

        PR fortran/29314
        * gfortran.dg/automatic_default_init_1.f90: New test.

        PR fortran/29387
        * trans-intrinsic.c (gfc_conv_intrinsic_len): Rearrange to have
        a specific case for EXPR_VARIABLE and, in default, build an ss
        to call gfc_conv_expr_descriptor for array expressions..

        PR fortran/29490
        * trans-expr.c (gfc_set_interface_mapping_bounds): In the case
        that GFC_TYPE_ARRAY_LBOUND is not available, use descriptor
        values for it and GFC_TYPE_ARRAY_UBOUND.

        PR fortran/29641
        * trans-types.c (gfc_get_derived_type): If the derived type
        namespace has neither a parent nor a proc_name, set NULL for
        the search namespace.

        PR fortran/29565
        * gfortran.dg/gfortran.dg/aliasing_dummy_3.f90: New test.


Added:
   
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/actual_array_interface_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/aliasing_dummy_3.f90
   
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/automatic_default_init_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/data_char_3.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/intrinsic_actual_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/nullify_3.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/result_default_init_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_types_11.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_types_12.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/data.c
    branches/gcc-4_1-branch/gcc/fortran/dump-parse-tree.c
    branches/gcc-4_1-branch/gcc/fortran/f95-lang.c
    branches/gcc-4_1-branch/gcc/fortran/gfortran.h
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/st.c
    branches/gcc-4_1-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_1-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_1-branch/gcc/fortran/trans-stmt.h
    branches/gcc-4_1-branch/gcc/fortran/trans-types.c
    branches/gcc-4_1-branch/gcc/fortran/trans.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

end of thread, other threads:[~2006-11-10 21:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-06 14:29 [Bug fortran/29371] New: Coredump when using -fbounds-check with pointer & nullify tobias dot burnus at physik dot fu-berlin dot de
2006-10-07 21:23 ` [Bug fortran/29371] " pault at gcc dot gnu dot org
2006-10-07 21:24 ` pault at gcc dot gnu dot org
2006-10-11 20:43 ` pault at gcc dot gnu dot org
2006-10-12  0:15 ` patchapp at dberlin dot org
2006-10-14 13:10 ` pault at gcc dot gnu dot org
2006-10-14 13:19 ` pault at gcc dot gnu dot org
2006-11-10 21:53 ` pault 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).