Blame test/strnum1.awk

Packit 575503
# Date: Tue, 04 Jul 2006 21:06:14 +0200 (MEST)
Packit 575503
# From: Heiner Marxen <Heiner.Marxen@DrB.Insel.DE>
Packit 575503
# Subject: conversion error
Packit 575503
# To: bug-gawk@gnu.org
Packit 575503
# Message-id: <200607041906.k64J6Eqa019360@drb9.drb.insel.de>
Packit 575503
# 
Packit 575503
# Hello,
Packit 575503
# 
Packit 575503
# The following awk script fails for gawk 3.1.4 and 3.1.5.
Packit 575503
# Older versions did not do this, but I cannot say, how old they were.
Packit 575503
# 
Packit 575503
BEGIN {
Packit 575503
    if( 0 ) {		#ok
Packit 575503
	t = "8"
Packit 575503
    }else {		#fails
Packit 575503
	t = ""
Packit 575503
	t = t "8"
Packit 575503
    }
Packit 575503
    printf("8  = %d\n", 0+t)	# ok without this line
Packit 575503
    t = t "8"			# does not invalidate numeric interpretation
Packit 575503
    printf("88 = %s\n", 0+t)
Packit 575503
    ## The above prints "88 = 8" with gawk 3.1.4 and 3.1.5
Packit 575503
}
Packit 575503
# 
Packit 575503
# 
Packit 575503
# The following one-liner already exhibits the bug:
Packit 575503
# 
Packit 575503
# gawk 'BEGIN{t=""; t=t "8";printf("8=%d\n", 0+t);t=t "8";printf("88=%s\n", 0+t)}'
Packit 575503
# 
Packit 575503
# 
Packit 575503
# Preliminary observation: under somewhat strange conditions a variable
Packit 575503
# does retain its numeric interpretation although something is appended to it.
Packit 575503
# -- 
Packit 575503
# Heiner Marxen				http://www.drb.insel.de/~heiner/
Packit 575503
#