bug-gawk
[Top][All Lists]
Advanced

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

A naughty function call


From: Wolfgang Laun
Subject: A naughty function call
Date: Mon, 19 Jul 2021 08:51:27 +0200

function srep(n, s){
    n *= length(s)
    if( n == 0 ) return ""
    while( length(s) < n ) {
        s = s s;
    return substr( s, 1, n );
}
BEGIN { x = srep( 200000000, "abc" ); } # to measure performance

On my Linux box running GNU Awk 5.0.1, the execution fails:
$ gawk -f srepDoubl.awk
Killed

In this simple example, it is immediately clear to the programmer that
memory allocation fails. But is this the intended diagnostic? I think it
might be a little more user-friendly.

Cheers
Wolfgang

PS: It seems preferable to measure the performance using repeated
executions of the function call with *reasonable *parameter combinations.


reply via email to

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