bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] can we get a warning for undefined behavior?


From: Ed Morton
Subject: [bug-gawk] can we get a warning for undefined behavior?
Date: Tue, 24 Jul 2018 07:23:09 -0500
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

I notice that these:

$ echo 'foo bar' | awk --lint '{NF--}1'        # UB: decrementing NF
foo

$ echo 'foo bar' | awk --lint 'END{print $0}'    # UB: using $0 in END
foo bar

$ echo 'foo bar' | awk --lint '/\o/'    # UB: backslash before literal char
foo bar

$ echo 'foo bar' | awk --lint '{print > "file" 1}'    # UB: unparenthesized right side of I/O redirection

don't produce a warning that they are undefined behavior per POSIX and therefore a gawk extension whereas this obviously does:

$ echo 'foo bar' | awk --lint '{split($1,t,"")}1'
awk: cmd. line:1: (FILENAME=- FNR=1) warning: split: null string for third arg is a gawk extension
foo bar

Any chance of getting a warning when run with --lint (or some other --report-ub flag?) if anything in a given gawk script was undefined by POSIX so a user has something they can run to tell them if their script is portable to all POSIX awks or not.

    Ed.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]