[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: evaluating "&&" order with div by zero in subsequent part.
From: |
Wolfgang Laun |
Subject: |
Re: evaluating "&&" order with div by zero in subsequent part. |
Date: |
Sun, 14 Aug 2022 15:20:51 +0200 |
On Sun, 14 Aug 2022 at 14:39, Ed Morton <mortoneccc@comcast.net> wrote:
> There's some inconsistency in the following division by zero treatment
>
> but then if we swap denominator $0 which has value 0 with literal 0:
>
> $ echo 0 | awk '{ print (0 && (4/0)) }'
> awk: cmd. line:1: error: division by zero attempted
Inserting another print before this one shows you that this is a *compile
time *error, as opposed to
$ echo 0 | awk '{ print "hiho"; print (0 || (4/(0))) }'
hiho
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: division by zero attempted
It's possible to discuss the extent of compile time evaluation but (since
it is not a requirement at all) I think we should accept the status quo. Of
course, if someone would like to invest hours of work to catch more cases
of literal expressions doing something naughty...
Cheers
Wolfgang