Created attachment 26078 [details] Program causing the ICE The attached program causes an ICE in gfc_get_derived_type, at fortran/trans-types.c:2401, both in version 4.6.2 and 4.7.0 20111212 (a very recent nightly build). The reported location is the same. It may be related to other reported bugs vis-a-vis gfc_get_derived_type, but as far as I can tell, they concern a different location in the source file. The report is: Driving: gfortran -v -o json json_problem.f90 -l gfortran -shared-libgcc Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=d:/gfortran47/bin/../libexec/gcc/i586-pc-mingw32/4.7.0/lto-wrapper.exe Target: i586-pc-mingw32 Configured with: ../gcc-trunk/configure --prefix=/mingw --enable-languages=c,fortran --with-gmp=/home/brad/gfortran/dependencies --disable-werror --enable-threads --disable-nls --build=i586-pc-mingw32 --enable-libgomp --enable-shared --disable-win32-registry --with-dwarf2 --disable-sjlj-exceptions --enable-lto Thread model: win32 gcc version 4.7.0 20111212 (experimental) [trunk revision 182257] (GCC) COLLECT_GCC_OPTIONS='-v' '-o' 'json.exe' '-shared-libgcc' '-mtune=pentium' '-march=pentium' d:/gfortran47/bin/../libexec/gcc/i586-pc-mingw32/4.7.0/f951.exe json_problem.f90 -quiet -dumpbase json_problem.f90 -mtune=pentium -march=pentium -auxbase json_problem -version -fintrinsic-modules-path d:/gfortran47/bin/../lib/gcc/i586-pc-mingw32/4.7.0/finclude -o e:\Temp\cc481Bzh.s GNU Fortran (GCC) version 4.7.0 20111212 (experimental) [trunk revision 182257] (i586-pc-mingw32) compiled by GNU C version 4.7.0 20111212 (experimental) [trunk revision 182257], GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU Fortran (GCC) version 4.7.0 20111212 (experimental) [trunk revision 182257] (i586-pc-mingw32) compiled by GNU C version 4.7.0 20111212 (experimental) [trunk revision 182257], GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 json_problem.f90:50:0: internal compiler error: in gfc_get_derived_type, at fortran/trans-types.c:2401 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Regards, Arjen
I think it is a duplicate of pr47545, pr48654, pr49050, pr51075, and pr51393 (note that only pr48654 is marked as a duplicate of pr47545; if there is an agreement about it, I can mark the other PRs as duplicate). From http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49050#c2 : It is known that deferred character length components do not work - they have not been implemented. I think we really should add a gfc_error("Sorry not implemented") as it is not the first such bug has been reported. * * * By the way, the documentation states this - albeit a bit hidden: http://gcc.gnu.org/gcc-4.6/changes.html#fortran http://gcc.gnu.org/wiki/GFortran#GCC4.6 "Deferred type parameter: For scalar allocatable and pointer variables the character length can be deferred." (In particular: For components and for arrays, the length cannot be deferred.) And a bit more explicitly: http://gcc.gnu.org/wiki/Fortran2003Status http://gcc.gnu.org/onlinedocs/gfortran/Fortran-2003-status.html
Hi Dominique, thanks for looking into this. Such an error message would be more convenient than the ICE we get now. Regards, Arjen On 2011-12-14 11:26, dominiq at lps dot ens.fr wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51550 > > --- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-12-14 10:26:05 UTC --- > I think it is a duplicate of pr47545, pr48654, pr49050, pr51075, and pr51393 > (note that only pr48654 is marked as a duplicate of pr47545; if there is an > agreement about it, I can mark the other PRs as duplicate). From > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49050#c2 : > > It is known that deferred character length components do not work - they have > not been implemented. I think we really should add a gfc_error("Sorry not > implemented") as it is not the first such bug has been reported. > > * * * > > By the way, the documentation states this - albeit a bit hidden: > > http://gcc.gnu.org/gcc-4.6/changes.html#fortran > http://gcc.gnu.org/wiki/GFortran#GCC4.6 > "Deferred type parameter: For scalar allocatable and pointer variables > the character length can be deferred." > (In particular: For components and for arrays, the length cannot be deferred.) > > And a bit more explicitly: > http://gcc.gnu.org/wiki/Fortran2003Status > http://gcc.gnu.org/onlinedocs/gfortran/Fortran-2003-status.html > DISCLAIMER: This message is intended exclusively for the addressee(s) and may contain confidential and privileged information. If you are not the intended recipient please notify the sender immediately and destroy this message. Unauthorized use, disclosure or copying of this message is strictly prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, The Netherlands, Commercial Registration Number 41146461, is not liable in any way whatsoever for consequences and/or damages resulting from the improper, incomplete and untimely dispatch, receipt and/or content of this e-mail.
Author: burnus Date: Thu Dec 15 15:18:33 2011 New Revision: 182372 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182372 Log: 2011-12-15 Tobias Burnus <burnus@net-b.de> PR fortran/51550 PR fortran/47545 PR fortran/49050 PR fortran/51075 * resolve.c (resolve_fl_derived0): Print not-implemented error for deferred-length character components. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c
Author: burnus Date: Thu Dec 15 15:25:32 2011 New Revision: 182373 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182373 Log: 2011-12-15 Tobias Burnus <burnus@net-b.de> PR fortran/51550 PR fortran/47545 PR fortran/49050 PR fortran/51075 * resolve.c (resolve_fl_derived0): Print not-implemented error for deferred-length character components. Modified: branches/gcc-4_6-branch/gcc/fortran/ChangeLog branches/gcc-4_6-branch/gcc/fortran/resolve.c
The ICE is fixed - but deferred-length character components are not supported: Instead of an internal compiler error, one now gets a "not yet implemented" error. Its implementation of is now tracked at PR 51976. *** This bug has been marked as a duplicate of bug 51976 ***
I am working on fixing the remaining issue open to resolve this problem completely. During inspection of your code I figured, that the implementation of add_key_only () does not work. I had to change it this way: subroutine add_key_only( json_object, key ) type(json_data), target :: json_object character(len=*) :: key type(json_value), pointer :: value type(json_value), pointer :: last last => json_object%key_value if (associated (last)) then do while ( associated(last%next) ) write(*,*) 'Key found: ', last%key last => last%next enddo end if allocate( value ) allocate( character(len=len(key)) :: value%key ) value%key = key write(*,*) 'Inserting key: ', value%key, ', len: ', len(value%key) if (associated (last)) then last%next => value else json_object%key_value => value end if end subroutine add_key_only Which now works as expected.