public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47042] New: ICE with character pointer in function
@ 2010-12-22 14:02 jvdelisle at gcc dot gnu.org
  2011-01-29 16:16 ` [Bug fortran/47042] " dominiq at lps dot ens.fr
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2010-12-22 14:02 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ICE with character pointer in function
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jvdelisle@gcc.gnu.org


I am not sure this is valid code, but it gives and ICE.  There is no ICE if the
ptmp pointer is removed or the function is compiled outside the program block.

program bug

contains
function get_cstring (c_str, maxlen, c_term_char)
  use iso_c_binding, only: c_ptr, c_char, c_null_char
  character(kind=c_char, len=maxlen)     :: get_cstring
  character(kind=c_char,len=1), optional :: c_term_char
  character(kind=c_char), pointer        :: ptmp
  type(c_ptr)                            :: c_str
  integer                                :: i, maxlen

  call c_f_pointer (c_str, ptmp)
  do i=1,maxlen
    get_cstring(i:i) = ptmp(i)
    if (ptmp(i) == c_null_char) goto 10

    if (present(c_term_char).and.ptmp(i) == c_term_char) goto 10
  end do
  return
 10 continue
end function

end program


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
@ 2011-01-29 16:16 ` dominiq at lps dot ens.fr
  2011-01-29 17:37 ` burnus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-01-29 16:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.01.29 13:53:01
     Ever Confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-01-29 13:53:01 UTC ---
I confirm the ICE on *-apple-darwin* on trunk:
pr47042.f90: In function 'get_cstring':
pr47042.f90:9:0: internal compiler error: in build_function_decl, at
fortran/trans-decl.c:1683

The code in comment #0 compiles with gfortran 4.5 (4.5.0 and 4.5.2 r167027) and
4.4.4, but fails to link because c_f_pointer is not found. So it looks like a
regression. However if I remove the ONLY clause, I get an ICE with the versions
I have tested:

4.6)
gimplification failed:
ptmp <addr_expr 0x141d04540
    type <pointer_type 0x141e02c78
        type <function_type 0x141e02bd0 type <void_type 0x141d12d20 void>
            QI
            size <integer_cst 0x141d014b0 constant 8>
            unit size <integer_cst 0x141d014d8 constant 1>
            align 8 symtab 0 alias set -1 canonical type 0x141e02b28
            attributes <tree_list 0x141e00a28
                purpose <identifier_node 0x141dda898 fn spec>
                value <tree_list 0x141e00a00
                    value <string_cst 0x141dfd220 constant "..R">>>
            arg-types <tree_list 0x141e009b0 value <reference_type 0x141e02a80>
                chain <tree_list 0x141e009d8 value <integer_type 0x141d12498
integer(kind=4)>
                    chain <tree_list 0x141d01f50 value <void_type 0x141d12d20
void>>>>
            pointer_to_this <pointer_type 0x141e02c78>>
        unsigned DI
        size <integer_cst 0x141d017a8 constant 64>
        unit size <integer_cst 0x141d017d0 constant 8>
        align 64 symtab 0 alias set -1 canonical type 0x141e02d20>
    constant
    arg 0 <function_decl 0x141dfee00 ptmp type <function_type 0x141e02bd0>
        addressable static QI file pr47042_db_4.f90 line 6 col 0 align 8
context <function_decl 0x141dfec00 get_cstring>
        result <result_decl 0x141d0a380 D.1542 type <void_type 0x141d12d20
void>
            ignored VOID file pr47042_db_4.f90 line 6 col 0
            align 8 context <function_decl 0x141dfee00 ptmp>>>
    pr47042_db_4.f90:6:0>
pr47042_db_4.f90: In function 'get_cstring':
pr47042_db_4.f90:6:0: internal compiler error: gimplification failed

4.5)
pr47042_db_4.f90: In function 'get_cstring':
pr47042_db_4.f90:10:0: internal compiler error: in gimplify_expr, at
gimplify.c:7362

4.4)
pr47042_db_4.f90: In function 'get_cstring':
pr47042_db_4.f90:2: internal compiler error: in fold_convert, at
fold-const.c:2654

So for the time being, I refrain to mark this pr as a regression.
The backtrace for 4.6 is

#0  fancy_abort (file=0x1009d44c8 "../../work/gcc/fortran/trans-decl.c",
line=1683, function=0x100a46c00 "build_function_decl") at
../../work/gcc/diagnostic.c:893
#1  0x00000001000c8326 in build_function_decl (sym=0x141c17410, global=0 '\0')
at ../../work/gcc/fortran/trans-decl.c:1680


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
  2011-01-29 16:16 ` [Bug fortran/47042] " dominiq at lps dot ens.fr
@ 2011-01-29 17:37 ` burnus at gcc dot gnu.org
  2011-01-30 18:21 ` burnus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-29 17:37 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-29 16:39:57 UTC ---
NAG shows the error:
  POINTER function PTMP needs an explicit interface

Intel the error:
  This name has not been declared as an array or a function.   [PTMP]
    get_cstring(i:i) = ptmp(i)
-----------------------^

g95:
  Error: POINTER function 'ptmp' at (1) must have an explicit interface

"A procedure other than a statement function shall have an explicit interface
if it is referenced and [...]
(3) the procedure has a result that
    (a) is an array,
    (b) is a pointer or is allocatable, or [...]"
(F2008, "12.4.2.2 Explicit interface")


One could add such a check in  gfc_procedure_use:

  if (sym->attr.if_source == IFSRC_UNKNOWN)
    {
      [...]
      if (sym->attr.pointer && sym->attr.proc != PROC_ST_FUNCTION)
        {
          gfc_error ("");

Possibly also needed for ALLOCATABLE and maybe even with Dimension?


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
  2011-01-29 16:16 ` [Bug fortran/47042] " dominiq at lps dot ens.fr
  2011-01-29 17:37 ` burnus at gcc dot gnu.org
@ 2011-01-30 18:21 ` burnus at gcc dot gnu.org
  2011-01-30 18:22 ` burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-30 18:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-30 18:16:15 UTC ---
Author: burnus
Date: Sun Jan 30 18:16:12 2011
New Revision: 169414

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169414
Log:
2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * interface.c (gfc_procedure_use): Add explicit interface check
        * for
        pointer/allocatable functions.

2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * gfortran.dg/interface_34.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/interface_34.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-01-30 18:21 ` burnus at gcc dot gnu.org
@ 2011-01-30 18:22 ` burnus at gcc dot gnu.org
  2011-01-30 19:02 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-30 18:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-30 18:17:33 UTC ---
Author: burnus
Date: Sun Jan 30 18:17:29 2011
New Revision: 169415

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169415
Log:
2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * resolve.c (resolve_fl_procedure): Reject stmt functions
        with pointer/allocatable attribute.

2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * gfortran.dg/stmt_func_1.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/stmt_func_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-01-30 18:22 ` burnus at gcc dot gnu.org
@ 2011-01-30 19:02 ` burnus at gcc dot gnu.org
  2011-01-30 19:03 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-30 19:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-30 18:19:08 UTC ---
FIXED on the 4.6 trunk.

Thanks for the bug report!


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-01-30 19:02 ` burnus at gcc dot gnu.org
@ 2011-01-30 19:03 ` burnus at gcc dot gnu.org
  2011-01-30 19:24 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-30 19:03 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-30 18:19:29 UTC ---
really close as fixed


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-01-30 19:03 ` burnus at gcc dot gnu.org
@ 2011-01-30 19:24 ` burnus at gcc dot gnu.org
  2011-02-02 18:18 ` dnovillo at gcc dot gnu.org
  2011-02-02 18:23 ` dnovillo at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-30 19:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-30 18:21:08 UTC ---
(In reply to comment #4)
> New Revision: 169415
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169415

That commit was supposed to be for PR 47542.


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2011-01-30 19:24 ` burnus at gcc dot gnu.org
@ 2011-02-02 18:18 ` dnovillo at gcc dot gnu.org
  2011-02-02 18:23 ` dnovillo at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-02-02 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Diego Novillo <dnovillo at gcc dot gnu.org> 2011-02-02 18:04:50 UTC ---
Author: dnovillo
Date: Wed Feb  2 18:04:41 2011
New Revision: 169698

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169698
Log:
2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * interface.c (gfc_procedure_use): Add explicit interface check
        * for
        pointer/allocatable functions.

2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * gfortran.dg/interface_34.f90: New.

Added:
    branches/google/integration/gcc/testsuite/gfortran.dg/interface_34.f90
Modified:
    branches/google/integration/gcc/fortran/ChangeLog
    branches/google/integration/gcc/fortran/interface.c
    branches/google/integration/gcc/testsuite/ChangeLog


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

* [Bug fortran/47042] ICE with character pointer in function
  2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2011-02-02 18:18 ` dnovillo at gcc dot gnu.org
@ 2011-02-02 18:23 ` dnovillo at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-02-02 18:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Diego Novillo <dnovillo at gcc dot gnu.org> 2011-02-02 18:05:12 UTC ---
Author: dnovillo
Date: Wed Feb  2 18:04:58 2011
New Revision: 169699

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169699
Log:
2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * resolve.c (resolve_fl_procedure): Reject stmt functions
        with pointer/allocatable attribute.

2011-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47042
        * gfortran.dg/stmt_func_1.f90: New.

Added:
    branches/google/integration/gcc/testsuite/gfortran.dg/stmt_func_1.f90
Modified:
    branches/google/integration/gcc/fortran/ChangeLog
    branches/google/integration/gcc/fortran/resolve.c
    branches/google/integration/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2011-02-02 18:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-22 14:02 [Bug fortran/47042] New: ICE with character pointer in function jvdelisle at gcc dot gnu.org
2011-01-29 16:16 ` [Bug fortran/47042] " dominiq at lps dot ens.fr
2011-01-29 17:37 ` burnus at gcc dot gnu.org
2011-01-30 18:21 ` burnus at gcc dot gnu.org
2011-01-30 18:22 ` burnus at gcc dot gnu.org
2011-01-30 19:02 ` burnus at gcc dot gnu.org
2011-01-30 19:03 ` burnus at gcc dot gnu.org
2011-01-30 19:24 ` burnus at gcc dot gnu.org
2011-02-02 18:18 ` dnovillo at gcc dot gnu.org
2011-02-02 18:23 ` dnovillo at gcc dot gnu.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).