public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/36319]  New: Segfault with wide characters in DATA
@ 2008-05-24  2:28 jvdelisle at gcc dot gnu dot org
  2008-05-24  2:35 ` [Bug fortran/36319] " jvdelisle at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-05-24  2:28 UTC (permalink / raw)
  To: gcc-bugs

The following code draws a compile time segfault.  This is derived from
data_array_1.f90 that I have modified while working on wide character I/O.

program chkdata
    integer, parameter,dimension(4) :: myint = [ 4,3,2,1 ]
    character(len=3, kind=4), parameter, dimension(3) :: mychar = [ "abc",
"def", "ghi" ]
    character(50) :: buffer
    integer :: a(5)
    character(5) :: c(5)
    data a(1:2) / myint(4), myint(2) /
    data a(3:5) / myint(1), myint(3), myint(1) /
    data c / mychar(1), mychar(2), mychar(3), mychar(1), mychar(2) /
    buffer = ""
    if (any(a.ne.[1,3,4,2,4])) call abort
    write(buffer,'(5(a))')c
    if (buffer.ne."abc  def  ghi  abc  def  ") call abort
end program chkdata

Starting program: /home/jerry/bin/f951 test2.f90

Program received signal SIGSEGV, Segmentation fault.
0x0000003ff067b40b in memcpy () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install gmp.x86_64 mpfr.x86_64
(gdb) bt
#0  0x0000003ff067b40b in memcpy () from /lib64/libc.so.6
#1  0x000000000046875e in gfc_convert_char_constant (e=0x106d6d0, 
    type=<value optimized out>, kind=4)
    at ../../gcc44/gcc/fortran/simplify.c:4832
#2  0x000000000042a901 in do_simplify (specific=0x1068ba0, e=0x106d9a0)
    at ../../gcc44/gcc/fortran/intrinsic.c:3286
#3  0x000000000042ac11 in gfc_convert_chartype (expr=0x106d9a0, 
    ts=0x7ffffad42a58) at ../../gcc44/gcc/fortran/intrinsic.c:3820
#4  0x000000000042286d in gfc_check_assign (lvalue=0x7ffffad42a50, 
    rvalue=0x106d9a0, conform=1) at ../../gcc44/gcc/fortran/expr.c:2855
#5  0x00000000004229a0 in gfc_check_assign_symbol (sym=0x106d530, 
    rvalue=0x106d9a0) at ../../gcc44/gcc/fortran/expr.c:3029
#6  0x000000000041963d in add_init_expr_to_sym (name=<value optimized out>, 
    initp=0x7ffffad42c50, var_locus=0x7ffffad42c10)
    at ../../gcc44/gcc/fortran/decl.c:1231
#7  0x000000000041a01d in gfc_match_data_decl ()
    at ../../gcc44/gcc/fortran/decl.c:1776
#8  0x00000000004512d3 in match_word (str=0x2aaaaf664010 "", 
    subr=0x419da0 <gfc_match_data_decl>, old_locus=0x7ffffad42cd0)
    at ../../gcc44/gcc/fortran/parse.c:64
#9  0x00000000004518a3 in decode_statement ()
    at ../../gcc44/gcc/fortran/parse.c:280
#10 0x000000000045292b in next_statement ()


-- 
           Summary: Segfault with wide characters in DATA
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jvdelisle at gcc dot gnu dot org
  GCC host triplet: x86_64-unknown-linux-gnu


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


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

* [Bug fortran/36319] Segfault with wide characters in DATA
  2008-05-24  2:28 [Bug fortran/36319] New: Segfault with wide characters in DATA jvdelisle at gcc dot gnu dot org
@ 2008-05-24  2:35 ` jvdelisle at gcc dot gnu dot org
  2008-05-24  2:48 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-05-24  2:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jvdelisle at gcc dot gnu dot org  2008-05-24 02:34 -------
Reduced test case:

program chkdata
    integer, parameter :: k4=4
    character(len=3, kind=4), parameter, dimension(3) :: mychar = [ "abc",
"def", "ghi" ]
end program chkdata

Note the initializers are kind=1.


-- 


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


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

* [Bug fortran/36319] Segfault with wide characters in DATA
  2008-05-24  2:28 [Bug fortran/36319] New: Segfault with wide characters in DATA jvdelisle at gcc dot gnu dot org
  2008-05-24  2:35 ` [Bug fortran/36319] " jvdelisle at gcc dot gnu dot org
@ 2008-05-24  2:48 ` jvdelisle at gcc dot gnu dot org
  2008-05-24  6:52 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-05-24  2:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2008-05-24 02:47 -------
Here is a variation:
    integer, parameter :: k4=4
    character(len=3, kind=4), parameter, dimension(3) :: mychar = &
         &    [ k4_"abc", k4_"def", k4_"ghi" ]

This gives an error.  Is this valid?


-- 


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


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

* [Bug fortran/36319] Segfault with wide characters in DATA
  2008-05-24  2:28 [Bug fortran/36319] New: Segfault with wide characters in DATA jvdelisle at gcc dot gnu dot org
  2008-05-24  2:35 ` [Bug fortran/36319] " jvdelisle at gcc dot gnu dot org
  2008-05-24  2:48 ` jvdelisle at gcc dot gnu dot org
@ 2008-05-24  6:52 ` fxcoudert at gcc dot gnu dot org
  2008-05-28 21:13 ` fxcoudert at gcc dot gnu dot org
  2008-05-28 22:19 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-05-24  6:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2008-05-24 06:52 -------
I'm aware of both bugs (found them indepedently while testing some more string
intrinsics) and have fixed them with my next patch (will submit in a few days).


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-05-24 06:52:08
               date|                            |


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


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

* [Bug fortran/36319] Segfault with wide characters in DATA
  2008-05-24  2:28 [Bug fortran/36319] New: Segfault with wide characters in DATA jvdelisle at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-05-24  6:52 ` fxcoudert at gcc dot gnu dot org
@ 2008-05-28 21:13 ` fxcoudert at gcc dot gnu dot org
  2008-05-28 22:19 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-05-28 21:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fxcoudert at gcc dot gnu dot org  2008-05-28 21:12 -------
Subject: Bug 36319

Author: fxcoudert
Date: Wed May 28 21:11:39 2008
New Revision: 136129

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136129
Log:
        PR fortran/36319

        * intrinsic.c (gfc_convert_chartype): Don't mark conversion
        function as pure.
        * trans-array.c (gfc_trans_array_ctor_element): Divide element
        size by the size of one character to obtain length.
        * iresolve.c (gfc_resolve_cshift): Call the _char4 variant when
        appropriate.
        (gfc_resolve_eoshift): Likewise.
        * trans-intrinsic.c (gfc_conv_intrinsic_ctime): Minor beautification.
        (gfc_conv_intrinsic_fdate): Minor beautification.
        (gfc_conv_intrinsic_ttynam): Minor beautification.
        (gfc_conv_intrinsic_minmax_char): Allow all character kinds.
        (size_of_string_in_bytes): New function.
        (gfc_conv_intrinsic_size): Call size_of_string_in_bytes for
        character expressions.
        (gfc_conv_intrinsic_sizeof): Likewise.
        (gfc_conv_intrinsic_array_transfer): Likewise.
        (gfc_conv_intrinsic_trim): Allow all character kinds. Minor
        beautification.
        (gfc_conv_intrinsic_repeat): Fix comment typo.
        * simplify.c (gfc_convert_char_constant): Take care of conversion
        of array constructors.

        * intrinsics/string_intrinsics_inc.c (string_index): Return
        correct value for zero-length substring.
        * intrinsics/cshift0.c: Add _char4 variant.
        * intrinsics/eoshift0.c (eoshift0): Allow filler to be a pattern
        wider than a single byte. Add _char4 variant and use above
        functionality.
        * intrinsics/eoshift2.c (eoshift2): Likewise.
        * m4/eoshift1.m4: Likewise.
        * m4/eoshift3.m4: Likewise.
        * m4/cshift1.m4: Add _char4 variants.
        * gfortran.map (GFORTRAN_1.1): Add _gfortran_cshift0_1_char4,
        _gfortran_cshift0_2_char4, _gfortran_cshift0_4_char4,
        _gfortran_cshift0_8_char4, _gfortran_cshift1_16_char4,
        _gfortran_cshift1_4_char4, _gfortran_cshift1_8_char4,
        _gfortran_eoshift0_1_char4, _gfortran_eoshift0_2_char4,
        _gfortran_eoshift0_4_char4, _gfortran_eoshift0_8_char4,
        _gfortran_eoshift1_16_char4, _gfortran_eoshift1_4_char4,
        _gfortran_eoshift1_8_char4, _gfortran_eoshift2_1_char4,
        _gfortran_eoshift2_2_char4, _gfortran_eoshift2_4_char4,
        _gfortran_eoshift2_8_char4, _gfortran_eoshift3_16_char4,
        _gfortran_eoshift3_4_char4 and _gfortran_eoshift3_8_char4.
        * generated/eoshift3_4.c: Regenerate.
        * generated/eoshift1_8.c: Regenerate.
        * generated/eoshift1_16.c: Regenerate.
        * generated/cshift1_4.c: Regenerate.
        * generated/eoshift1_4.c: Regenerate.
        * generated/eoshift3_8.c: Regenerate.
        * generated/eoshift3_16.c: Regenerate.
        * generated/cshift1_8.c: Regenerate.
        * generated/cshift1_16.c: Regenerate.

        * gfortran.dg/widechar_5.f90: New file.
        * gfortran.dg/widechar_6.f90: New file.
        * gfortran.dg/widechar_7.f90: New file.
        * gfortran.dg/widechar_intrinsics_5.f90: Uncomment the lines
        testing the SPREAD intrinsic.
        * gfortran.dg/widechar_intrinsics_6.f90: New file.
        * gfortran.dg/widechar_intrinsics_7.f90: New file.
        * gfortran.dg/widechar_intrinsics_8.f90: New file.
        * gfortran.dg/widechar_intrinsics_9.f90: New file.
        * gfortran.dg/widechar_intrinsics_10.f90: New file.

Added:
    trunk/gcc/testsuite/gfortran.dg/widechar_5.f90
    trunk/gcc/testsuite/gfortran.dg/widechar_6.f90
    trunk/gcc/testsuite/gfortran.dg/widechar_7.f90
    trunk/gcc/testsuite/gfortran.dg/widechar_intrinsics_10.f90
    trunk/gcc/testsuite/gfortran.dg/widechar_intrinsics_6.f90
    trunk/gcc/testsuite/gfortran.dg/widechar_intrinsics_7.f90
    trunk/gcc/testsuite/gfortran.dg/widechar_intrinsics_8.f90
    trunk/gcc/testsuite/gfortran.dg/widechar_intrinsics_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/widechar_intrinsics_5.f90
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/generated/cshift1_16.c
    trunk/libgfortran/generated/cshift1_4.c
    trunk/libgfortran/generated/cshift1_8.c
    trunk/libgfortran/generated/eoshift1_16.c
    trunk/libgfortran/generated/eoshift1_4.c
    trunk/libgfortran/generated/eoshift1_8.c
    trunk/libgfortran/generated/eoshift3_16.c
    trunk/libgfortran/generated/eoshift3_4.c
    trunk/libgfortran/generated/eoshift3_8.c
    trunk/libgfortran/gfortran.map
    trunk/libgfortran/intrinsics/cshift0.c
    trunk/libgfortran/intrinsics/eoshift0.c
    trunk/libgfortran/intrinsics/eoshift2.c
    trunk/libgfortran/intrinsics/string_intrinsics_inc.c
    trunk/libgfortran/m4/cshift1.m4
    trunk/libgfortran/m4/eoshift1.m4
    trunk/libgfortran/m4/eoshift3.m4


-- 


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


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

* [Bug fortran/36319] Segfault with wide characters in DATA
  2008-05-24  2:28 [Bug fortran/36319] New: Segfault with wide characters in DATA jvdelisle at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-05-28 21:13 ` fxcoudert at gcc dot gnu dot org
@ 2008-05-28 22:19 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-05-28 22:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2008-05-28 22:18 -------
Fixed.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


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


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

end of thread, other threads:[~2008-05-28 22:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-24  2:28 [Bug fortran/36319] New: Segfault with wide characters in DATA jvdelisle at gcc dot gnu dot org
2008-05-24  2:35 ` [Bug fortran/36319] " jvdelisle at gcc dot gnu dot org
2008-05-24  2:48 ` jvdelisle at gcc dot gnu dot org
2008-05-24  6:52 ` fxcoudert at gcc dot gnu dot org
2008-05-28 21:13 ` fxcoudert at gcc dot gnu dot org
2008-05-28 22:19 ` fxcoudert 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).