With the patch I get an ICE when compiling gfortran.dg/allocate_error_5.f90

(lldb) target create 
"/opt/gcc/gcc6p-233563p2/libexec/gcc/x86_64-apple-darwin15.3.0/6.0.0/f951"
Current executable set to 
'/opt/gcc/gcc6p-233563p2/libexec/gcc/x86_64-apple-darwin15.3.0/6.0.0/f951' 
(x86_64).
(lldb) run /opt/gcc/_clean/gcc/testsuite/gfortran.dg/allocate_error_5.f90
Process 18138 launched: 
'/opt/gcc/gcc6p-233563p2/libexec/gcc/x86_64-apple-darwin15.3.0/6.0.0/f951' 
(x86_64)
 gProcess 18138 stopped
* thread #1: tid = 0x2ebfe4a, 0x00000001000d5679 
f951`(chain=0x00007fff5fbfef20, expr=0x00000001427c56b8, 
front=<unavailable>)(tree *, tree, bool) + 41 at trans.c:1549, queue = 
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x500000004)
    frame #0: 0x00000001000d5679 f951`(chain=0x00007fff5fbfef20, 
expr=0x00000001427c56b8, front=<unavailable>)(tree *, tree, bool) + 41 at 
trans.c:1549
   1546 
   1547   if (*chain)
   1548     {
-> 1549       if (TREE_CODE (*chain) != STATEMENT_LIST)
   1550         {
   1551           tree tmp;
   1552 
(lldb) bt
* thread #1: tid = 0x2ebfe4a, 0x00000001000d5679 
f951`(chain=0x00007fff5fbfef20, expr=0x00000001427c56b8, 
front=<unavailable>)(tree *, tree, bool) + 41 at trans.c:1549, queue = 
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x500000004)
  * frame #0: 0x00000001000d5679 f951`(chain=0x00007fff5fbfef20, 
expr=0x00000001427c56b8, front=<unavailable>)(tree *, tree, bool) + 41 at 
trans.c:1549
    frame #1: 0x00000001000f045e 
f951`::gfc_null_and_pass_deferred_len(sym=0x0000000143d06d50, 
init=0x00007fff5fbfef20, loc=0x00007fff5fbfef10) + 174 at trans-decl.c:3965
    frame #2: 0x00000001000f9dba 
f951`gfc_trans_deferred_vars(proc_sym=0x0000000143d06a50, 
block=0x00007fff5fbff0b0) + 2042 at trans-decl.c:4275
    frame #3: 0x00000001000fc5e4 
f951`gfc_generate_function_code(ns=<unavailable>) + 1332 at trans-decl.c:6269
    frame #4: 0x000000010008cb9c f951`gfc_parse_file() + 1644 at parse.c:5613
    frame #5: 0x00000001000d2d39 f951`::gfc_be_parse_file() + 57 at 
f95-lang.c:201
    frame #6: 0x00000001009ac32c f951`::compile_file() + 60 at toplev.c:465
    frame #7: 0x0000000100d9caaf f951`toplev::main(int, char**) + 1154 at 
toplev.c:1988
    frame #8: 0x0000000100d9c62d f951`toplev::main(this=<unavailable>, 
argc=<unavailable>, argv=<unavailable>) + 733
    frame #9: 0x0000000100d9e479 f951`main(argc=2, argv=0x00007fff5fbff318) + 
41 at main.c:39
    frame #10: 0x00007fff97c615ad libdyld.dylib`start + 1
    frame #11: 0x00007fff97c615ad libdyld.dylib`start + 1

Thanks for working on this PR,

Dominique

> Le 19 févr. 2016 à 09:47, Paul Richard Thomas <paul.richard.tho...@gmail.com> 
> a écrit :
> 
> Dear All,
> 
> This has proven to be a rather vexatious bug to fix. On the face of
> it, using the indirect reference to the passed string length for
> deferred character length functions should have worked at all levels
> of optimization. However, setting the string length within a do loop
> resulted in the change not being visible within the rest of the
> function scope, even though the correct result was returned. This was,
> on the face of it, the same mechanism used for both dummies and
> declared results, which works fine at all levels of optimization.
> 
> In order to be as conservative as possible at this stage in the
> release cycle, I have resorted to the belt and braces approach of
> using a local variable '..result', which is nulled and returned, as
> appropriate, in a new helper function. So that the compiled code is
> consistent, I have done the same for functions with and without
> explicitly declared result variables.
> 
> There is some dead code in 'gfc_get_symbol_decl', which could, with
> advantage, be replaced by a gcc_assert. In addition,
> gfc_trans_deferred_vars could do with some further tidying up to
> ensure that the logic is clear. These steps can easily be done now if
> other maintainers think that it is timely.
> 
> Bootstraps and regtests on FC21/x86_64 - OK for trunk?
> 
> Paul
> 
> 2016-02-19  Paul Thomas  <pa...@gcc.gnu.org>
> 
>    PR fortran/69423
>    * trans-decl.c (create_function_arglist): Deferred character
>    length functions, with and without declared results, address
>    the passed reference type as '.result' and the local string
>    length as '..result'.
>    (gfc_null_and_pass_deferred_len): Helper function to null and
>    return deferred string lengths, as needed.
>    (gfc_trans_deferred_vars): Call it, thereby reducing repeated
>    code, add call for deferred arrays and reroute pointer function
>    results. Avoid using 'tmp' for anything other that a temporary
>    tree by introducing 'type_of_array' for the arrayspec type.
> 
> 2016-02-19  Paul Thomas  <pa...@gcc.gnu.org>
> 
>    PR fortran/69423
>    * gfortran.dg/deferred_character_15.f90 : New test.
> <submit2.diff>

Reply via email to