Bug 30525 - [4.2, 4.1 only] character comparisons with padding
Summary: [4.2, 4.1 only] character comparisons with padding
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Thomas Koenig
URL:
Keywords: wrong-code
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2007-01-21 11:29 UTC by Thomas Koenig
Modified: 2007-01-30 20:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-01-21 11:31:46


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2007-01-21 11:29:59 UTC
The results should be consistent.  g77
gets this right.

$ cat char-comparison.f
      program main
      character*2 c2
      character*1 c1, c3, c4
C
C  Comparison between char(255) and space padding
C
      c2 = 'a' // char(255)
      c1 = 'a'
      print *, c2 .gt. c1
C
C  Comparison between char(255) and space
C
      c3 = ' '
      c4 = char(255)
      print *,c4 .gt. c3
      end
$ gfortran char-comparison.f && ./a.out
 F
 T
$ g77 char-comparison.f && ./a.out
 T
 T
Comment 1 Thomas Koenig 2007-01-21 11:31:46 UTC
A signed issue in compare_string.

I'll also have to check front end constant folding for this...
Comment 2 Thomas Koenig 2007-01-21 18:02:01 UTC
Here's a patch:

http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01726.html

Constant folding by the front end is OK, BTW.
Comment 3 Thomas Koenig 2007-01-21 20:52:03 UTC
Subject: Bug 30525

Author: tkoenig
Date: Sun Jan 21 20:51:53 2007
New Revision: 121035

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121035
Log:
2007-01-21  Thomas Koenig  <Thomas.Koenig@online.de>

	PR libfortran/30525
	* intrinsics/string_intrinsics.c(compare_string):  Make
	sure that comparisons are done unsigned.

2007-01-21  Thomas Koenig  <Thomas.Koenig@online.de>

	PR libfortran/30525
	* gfortran.dg/char_comparison_1.f:  New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/char_comparison_1.f
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/intrinsics/string_intrinsics.c

Comment 4 Thomas Koenig 2007-01-30 20:18:17 UTC
Subject: Bug 30525

Author: tkoenig
Date: Tue Jan 30 20:18:05 2007
New Revision: 121357

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121357
Log:
2007-01-30  Thomas Koenig  <Thomas.Koenig@online.de>

	Backport from trunk
	PR libfortran/30525
	* intrinsics/string_intrinsics.c(compare_string):  Make
	sure that comparisons are done unsigned.

2007-01-30  Thomas Koenig  <Thomas.Koenig@online.de>

	Backport from trunk
	PR libfortran/30525
	* gfortran.dg/char_comparison_1.f:  New test.


Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/char_comparison_1.f
Modified:
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_2-branch/libgfortran/ChangeLog
    branches/gcc-4_2-branch/libgfortran/intrinsics/string_intrinsics.c

Comment 5 Thomas Koenig 2007-01-30 20:18:51 UTC
Fixed on trunk and 4.2.  Closing.

One less for PR 19292!