Bug 24503 - varying string length character function result
Summary: varying string length character function result
Status: RESOLVED DUPLICATE of bug 18883
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 23675
  Show dependency treegraph
 
Reported: 2005-10-24 12:14 UTC by Remi BUTEL
Modified: 2005-10-27 10:26 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-10-24 16:31:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remi BUTEL 2005-10-24 12:14:17 UTC
* the exact version of GCC;
> gfortran -v

Utilisation des specs internes.
Target: i386-redhat-linux
Configuré avec: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Modèle de thread: posix
version gcc 4.0.1 20050727 (Red Hat 4.0.1-5)

    * the system type;
> cat /proc/version
Linux version 2.6.13-1.1526_FC4smp (bhcompile@hs20-bc1-6.build.redhat.com)
(gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Wed Sep 28 19:30:04 EDT 2005

    * the options given when GCC was configured/built;
> gfortran -v -save-temps -c bug.f90
GNU F95 version 4.0.1 20050727 (Red Hat 4.0.1-5) (i386-redhat-linux)
        compiled by GNU C version 4.0.1 20050727 (Red Hat 4.0.1-5).
heuristiques GGC: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

    * the complete command line that triggers the bug;
gfortran -c bug.f90

    * the compiler output (error messages, warnings, etc.); and
> gfortran -c bug.f90
bug.f90: In function ‘s_to_c’:
bug.f90:21: erreur interne du compilateur: dans gfc_finish_var_decl, à fortran/trans-decl.c:436
Veuillez soumettre un rapport complet d'anomalies,
avec le source pré-traité si nécessaire.
Consultez <URL:http://bugzilla.redhat.com/bugzilla> pour plus de détail.

    * the preprocessed file (*.i*) that triggers the bug, generated by adding -save-temps to the complete compilation command, or, in the case of a bug report for the GNAT front end, a complete set of source files (see below).
> cat bug.f90
MODULE ISO_VARYING_STRING

PRIVATE

TYPE VARYING_STRING
 PRIVATE
 CHARACTER,DIMENSION(:),POINTER :: chars
ENDTYPE VARYING_STRING

CHARACTER,PARAMETER :: blank = " "

PUBLIC :: s_to_c
 
CONTAINS

 FUNCTION s_to_c(string)
  type(VARYING_STRING),INTENT(IN)   :: string
  ! returns the characters of string as an automatically sized character
  CHARACTER(LEN=SIZE(string%chars)) :: s_to_c
  INTEGER                           :: lc
  lc=SIZE(string%chars)
  DO i=1,lc
    s_to_c(i:i) = string%chars(i)
  ENDDO
 ENDFUNCTION s_to_c

END MODULE ISO_VARYING_STRING
Comment 1 Andrew Pinski 2005-10-24 12:16:43 UTC
Here is what I get with the mainline of GCC:
 In file t.f90:12

PUBLIC :: s_to_c
               1
Error: 'string' is a PRIVATE type and cannot be a dummy argument of 's_to_c', which is PUBLIC at (1)
Comment 2 Erik Edelmann 2005-10-24 12:53:45 UTC
(In reply to comment #1)
> Here is what I get with the mainline of GCC:
>  In file t.f90:12
> 
> PUBLIC :: s_to_c
>                1
> Error: 'string' is a PRIVATE type and cannot be a dummy argument of 's_to_c',
> which is PUBLIC at (1)

Gfortran is correct; the code is invalid.  However, if we make it valid by declaring the type VARYING_STRING public too, we get the error message
of the OP.  Here's a reduced testcase

kl-nrb:~$ cat hum.f90
MODULE ISO_VARYING_STRING

CONTAINS

 FUNCTION s_to_c(chars)
  CHARACTER,DIMENSION(:),POINTER :: chars
  CHARACTER(LEN=SIZE(chars)) :: s_to_c
  s_to_c = ''
 ENDFUNCTION s_to_c

END MODULE ISO_VARYING_STRING
kl-nrb:~$ gfortran hum.f90
hum.f90: In function 's_to_c':
hum.f90:5: internal compiler error: in gfc_finish_var_decl, at fortran/trans-decl.c:444
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

I think I've seen this bug reported somewhere, but couldn't find it in a quick search.
Comment 3 Andrew Pinski 2005-10-24 13:56:03 UTC
(In reply to comment #2)
> I think I've seen this bug reported somewhere, but couldn't find it in a quick
> search.
Looks to be PR 23675.
Comment 4 eedelman 2005-10-24 16:31:42 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > I think I've seen this bug reported somewhere, but couldn't find it in a quick
> > search.
> Looks to be PR 23675.

Yes, they seem to be the same, except that PR 23675 demonstrates an other bug as well, namely the same one as in PR 22607.

I confirm this bug, and mark it as blocking PR 23675, and will do the same with PR 22607 (another possibility would be to mark both this and PR 22607 as duplicates of PR 23675, but since they are separate bugs I think there is some value in keeping them as separate PR:s)
Comment 5 Erik Edelmann 2005-10-27 09:25:48 UTC
Patch here: http://gcc.gnu.org/ml/fortran/2005-10/msg00587.html
Comment 6 eedelman 2005-10-27 10:26:19 UTC

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