NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/47840: awk string comparison of integer constant

The following reply was made to PR bin/47840; it has been noted by GNATS.

From: David Holland <>
Subject: Re: bin/47840: awk string comparison of integer constant
Date: Sat, 14 Feb 2015 10:59:34 +0000

 On Fri, May 24, 2013 at 07:55:00AM +0000, David Holland wrote:
  >  On Mon, May 20, 2013 at 11:05:03PM +0000, Valery Ushakov wrote:
  >   >  > Note that k < 10 is evaluated as a string comparison.
  >   >  > 
  >   >  > Is this required by some standard? gawk does the same thing, but it
  >   >  > definitely violates the POLA.
  >   >  
  >   >  Hmm, it does, indeed, but [...]
  >  Blah... all right then, can we at least warn if a numeric constant
  >  gets converted to a string value like this? It is reasonable to
  >  suppose that if I (or anyone else) intended a string value I would
  >  have written a string constant.
  >  The behavior I've just exhibited is just as nonsensical as that cited
  >  in that RATIONALE.
 Reading through this again, it seems that the problem is that in
    a[$1] = ($1 < 10)
 $1 is a numeric string because it's a field variable. But after the
 assignment the keys of a[] are not numeric strings, even though the
 value was copied from a numeric string. Maybe this is technically not
 an "assignment", but clearly the numeric string tag should be getting
 propagated here too.
 David A. Holland

Home | Main Index | Thread Index | Old Index