public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31487]  New: Character array initialization in derived type: bad zero padding
@ 2007-04-05 13:50 anlauf at gmx dot de
  2007-04-05 13:51 ` [Bug fortran/31487] " anlauf at gmx dot de
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: anlauf at gmx dot de @ 2007-04-05 13:50 UTC (permalink / raw)
  To: gcc-bugs

Hi,

here's an annoying one.  Default initializing a
character array in a derived type leads to zero
padded strings instead of space-padded ones.
E.g.

  ! This works correctly:
  character(len=16) ::    tdefi(2) = (/'0z1jan0000','1hr       '/)
  !                                     1234567890

  ! Broken in derived type:
  type t_ctl
     character(len=16) :: tdefi(2) = (/'0z1jan0000','1hr       '/)
     !                                  1234567890
  end type t_ctl


See the attached program for details.


-- 
           Summary: Character array initialization in derived type: bad zero
                    padding
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anlauf at gmx dot de
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
@ 2007-04-05 13:51 ` anlauf at gmx dot de
  2007-04-08 10:41 ` fxcoudert at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gmx dot de @ 2007-04-05 13:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from anlauf at gmx dot de  2007-04-05 14:51 -------
Created an attachment (id=13332)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13332&action=view)
Demo code


-- 


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
  2007-04-05 13:51 ` [Bug fortran/31487] " anlauf at gmx dot de
@ 2007-04-08 10:41 ` fxcoudert at gcc dot gnu dot org
  2007-04-16 14:37 ` tobi at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-04-08 10:41 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   GCC host triplet|i686-pc-linux-gnu           |
      Known to fail|                            |4.3.0
   Last reconfirmed|0000-00-00 00:00:00         |2007-04-08 11:41:37
               date|                            |


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
  2007-04-05 13:51 ` [Bug fortran/31487] " anlauf at gmx dot de
  2007-04-08 10:41 ` fxcoudert at gcc dot gnu dot org
@ 2007-04-16 14:37 ` tobi at gcc dot gnu dot org
  2007-04-16 14:38 ` tobi at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-04-16 14:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from tobi at gcc dot gnu dot org  2007-04-16 15:37 -------
I'll have a look.


-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (2 preceding siblings ...)
  2007-04-16 14:37 ` tobi at gcc dot gnu dot org
@ 2007-04-16 14:38 ` tobi at gcc dot gnu dot org
  2007-04-17 15:12 ` tobi at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-04-16 14:38 UTC (permalink / raw)
  To: gcc-bugs



-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tobi at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-04-08 11:41:37         |2007-04-16 15:38:02
               date|                            |


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (3 preceding siblings ...)
  2007-04-16 14:38 ` tobi at gcc dot gnu dot org
@ 2007-04-17 15:12 ` tobi at gcc dot gnu dot org
  2007-10-25  8:54 ` tobi at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-04-17 15:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from tobi at gcc dot gnu dot org  2007-04-17 16:12 -------
The strings aren't actually padded.  From the assembly output:
_ctl.1000:
        .ascii "0z1jan0000"
        .space 6
        .ascii "1hr       "
        .space 6
        .align 5
_tdefi.996:
        .ascii "0z1jan0000      "
        .ascii "1hr             "
        .const
In other words, they are put into the right memory locations, but without any
regard to their string nature.  I've not yet figured out where this goes wrong.


-- 


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (4 preceding siblings ...)
  2007-04-17 15:12 ` tobi at gcc dot gnu dot org
@ 2007-10-25  8:54 ` tobi at gcc dot gnu dot org
  2007-12-07 18:37 ` pault at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-10-25  8:54 UTC (permalink / raw)
  To: gcc-bugs



-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|tobi at gcc dot gnu dot org |unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (5 preceding siblings ...)
  2007-10-25  8:54 ` tobi at gcc dot gnu dot org
@ 2007-12-07 18:37 ` pault at gcc dot gnu dot org
  2007-12-07 23:05 ` dominiq at lps dot ens dot fr
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-07 18:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2007-12-07 18:37 -------
Created an attachment (id=14708)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14708&action=view)
Fix for PR - not yet regtested


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (6 preceding siblings ...)
  2007-12-07 18:37 ` pault at gcc dot gnu dot org
@ 2007-12-07 23:05 ` dominiq at lps dot ens dot fr
  2007-12-08  6:43 ` pault at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-12-07 23:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dominiq at lps dot ens dot fr  2007-12-07 23:05 -------
I have applied the patch in #4 and I have a lot of failures:

[ibook-dhum] f90/bug% cat pr30200_red.f90
   type test
    character(len=100) :: names(5)
   end type test
   type(test) :: keyword
   keyword%names=(/"a","b","c","d","e"/)
   END
[ibook-dhum] f90/bug% gfc pr30200_red.f90
f951: internal compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

I did not looked yet at all the failures, but all the one I have looked at
gives a bus error.


-- 


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (7 preceding siblings ...)
  2007-12-07 23:05 ` dominiq at lps dot ens dot fr
@ 2007-12-08  6:43 ` pault at gcc dot gnu dot org
  2007-12-08  6:50 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-08  6:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2007-12-08 06:43 -------
(In reply to comment #5)


> I did not looked yet at all the failures, but all the one I have looked at
> gives a bus error.

Thanks Dominique.  I'm looking at PR32129 first and then this.  I am sure that
this fix is fundamentally right but that I have just forgotten a check on the
existence of something.

Cheers

Paul


-- 


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (8 preceding siblings ...)
  2007-12-08  6:43 ` pault at gcc dot gnu dot org
@ 2007-12-08  6:50 ` pault at gcc dot gnu dot org
  2007-12-08 20:43 ` dominiq at lps dot ens dot fr
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-08  6:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pault at gcc dot gnu dot org  2007-12-08 06:50 -------
(In reply to comment #5)


> I did not looked yet at all the failures, but all the one I have looked at
> gives a bus error.

In fact, I do not check that the initializer is not NULL.

Paul


-- 


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (9 preceding siblings ...)
  2007-12-08  6:50 ` pault at gcc dot gnu dot org
@ 2007-12-08 20:43 ` dominiq at lps dot ens dot fr
  2007-12-09  9:17 ` pault at gcc dot gnu dot org
  2007-12-09  9:19 ` pault at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-12-08 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from dominiq at lps dot ens dot fr  2007-12-08 20:43 -------
Now works as advertized without regression on i686-apple-darwin9.


-- 


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (10 preceding siblings ...)
  2007-12-08 20:43 ` dominiq at lps dot ens dot fr
@ 2007-12-09  9:17 ` pault at gcc dot gnu dot org
  2007-12-09  9:19 ` pault at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-09  9:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pault at gcc dot gnu dot org  2007-12-09 09:17 -------
Subject: Bug 31487

Author: pault
Date: Sun Dec  9 09:17:24 2007
New Revision: 130719

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130719
Log:
2007-12-09  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/32129
        * dump-parse-tree.c (gfc_show_expr_n): New function for
        debugging.
        * gfortran.h : Add prototype for gfc_show_expr_n.
        * expr.c (simplify_constructor): Copy the constructor
        expression and try to simplify that.  If success, replace the
        original.  Otherwise discard the copy, keep going through
        the structure and return success.

        PR fortran/31487
        * decl.c (build_struct): Pad out default initializers with
        spaces to the component character length.

2007-12-09  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/32129
        * gfortran.dg/derived_comp_array_ref_6.f90: New test.
        * gfortran.dg/derived_comp_array_ref_7.f90: New test.

        PR fortran/31487
        * gfortran.dg/char_component_initializer_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/char_component_initializer_1.f90
    trunk/gcc/testsuite/gfortran.dg/derived_comp_array_ref_6.f90
    trunk/gcc/testsuite/gfortran.dg/derived_comp_array_ref_7.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/dump-parse-tree.c
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/31487] Character array initialization in derived type: bad zero padding
  2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
                   ` (11 preceding siblings ...)
  2007-12-09  9:17 ` pault at gcc dot gnu dot org
@ 2007-12-09  9:19 ` pault at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-09  9:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pault at gcc dot gnu dot org  2007-12-09 09:19 -------
Fixed on trunk

Paul


-- 

pault at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-12-09  9:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-05 13:50 [Bug fortran/31487] New: Character array initialization in derived type: bad zero padding anlauf at gmx dot de
2007-04-05 13:51 ` [Bug fortran/31487] " anlauf at gmx dot de
2007-04-08 10:41 ` fxcoudert at gcc dot gnu dot org
2007-04-16 14:37 ` tobi at gcc dot gnu dot org
2007-04-16 14:38 ` tobi at gcc dot gnu dot org
2007-04-17 15:12 ` tobi at gcc dot gnu dot org
2007-10-25  8:54 ` tobi at gcc dot gnu dot org
2007-12-07 18:37 ` pault at gcc dot gnu dot org
2007-12-07 23:05 ` dominiq at lps dot ens dot fr
2007-12-08  6:43 ` pault at gcc dot gnu dot org
2007-12-08  6:50 ` pault at gcc dot gnu dot org
2007-12-08 20:43 ` dominiq at lps dot ens dot fr
2007-12-09  9:17 ` pault at gcc dot gnu dot org
2007-12-09  9:19 ` pault 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).