bug-gawk
[Top][All Lists]
Advanced

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

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


From: arnold
Subject: Re: [bug-gawk] can we get a warning for undefined behavior?
Date: Tue, 24 Jul 2018 06:36:16 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Ed Morton <address@hidden> wrote:

> I notice that these:
>
> $ echo 'foo bar' | awk --lint '{NF--}1'        # UB: decrementing NF
> foo

Not undefined. Cite chapter and verse.

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

Possibly unspecified by POSIX, but I don't remember. Again, cite
chapter and verse please.

> $ 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

Also on these two.

Interestingly enough, gawk warns about unknown escapes in strings:

$ ./gawk --lint '"\q"' /dev/null
gawk: cmd. line:1: warning: escape sequence `\q' treated as plain `q'

I will look into something similar for regexps.

> 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.

Running with --posix will usually fatal on things that are gawk
extensions.  It's pretty strict.

With respect to undefined / unspecified behaviors, if you would be kind
enough to collect a full list of them, with links / quotes from the POSIX
standard, I will look at adding warnings into gawk.

Thanks,

Arnold



reply via email to

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