This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Optimize 'a ' as single char string too
- From: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>
- To: Tobias Burnus <tobias dot burnus at physik dot fu-berlin dot de>
- Cc: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>, Jakub Jelinek <jakub at redhat dot com>, fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 14 Jul 2010 12:23:58 +0200
- Subject: Re: [PATCH] Optimize 'a ' as single char string too
- References: <20100714090229.GA32101@physik.fu-berlin.de>
It was me that raised the question.
> b) For character comparison, TRIM does not play any role, cf.
> ?"For a character relational intrinsic operation, the operands are
> ?compared one character at a time in order, beginning with the first
> ?character of each character operand. If the operands are of unequal
> ?length, the shorter operand is treated as if it were extended on
> ?the right with blanks to the length of the longer operand. If both
> ?x1 and x2 are of zero length, x1 is equal to x2; if every character
> ?of x1 is the same as the character in the corresponding position in
> ?x2, x1 is equal to x2. Otherwise, at the first position where the
> ?character operands differ, the character operand x1 is considered
> ?to be less than x2 if the character value of x1 at this position
> ?precedes the value of x2 in the collating sequence (1.3); x1 is
> ?greater than x2 if the character value of x1 at this position
> ?follows the value of x2 in the collating sequence."
> ?(F2008, 18.104.22.168.1 Interpretation of relational intrinsic operations)
To which this is a satisfactory answer :-)
> Thus, the optimization of ignoring the tailing blanks for
> ?if (c .eq. 'a ') call abort
> seems to be fine.
Indeed - thanks for digging into the standard. I just wanted to be
sure that the trailing spaces had no lexographic value.