bug-gawk
[Top][All Lists]
Advanced

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

Re: SYMTAB array does not work properly. It is semi-read-only.


From: arnold
Subject: Re: SYMTAB array does not work properly. It is semi-read-only.
Date: Wed, 05 Apr 2023 04:16:14 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Thank you for your note.

SYMTAB is working as designed and as described in the manual.
The elements in SYMTAB are created as gawk parses your program; one
element is added for each global variable in your program.

You cannot "create" new global variables by adding new elements in SYMTAB.
In other words, SYMTAB reflects your program, not the other way around.

Thanks,

Arnold

Евгений <voltasar@gmail.com> wrote:

> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt 
> -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat 
> -Werror=format-security         -fstack-clash-protection -fcf-protection 
> -g -ffile-prefix-map=/build/gawk/src=/usr/src/debug/gawk -flto=auto -DNDEBUG
> uname output: Linux ideapad 6.1.21-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed 
> Mar 22 21:14:13 UTC 2023 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Gawk Version: 5.2.1
>
> Attestation 1:
>      I have read 
> https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
>      Yes
>
> Attestation 2:
>      I have not modified the sources before building gawk.
>      True
>
> Description:
> SYMTAB array does not work properly. It is semi-read-only.
> I thought it's like an 'eval' function in JavaScript, or a read-only 
> array. It is open for writing, but it can't be written without 
> immediately calling the variable just placed in it. This bug has been 
> around for a long time.
> Also sometimes SYMTAB lacks variables that were recently assigned.
>
> Repeat-By:
> $ gawk 'BEGIN{SYMTAB["foo"]="bar"}'
> gawk: cmd. line:1: fatal: cannot assign to arbitrary elements of SYMTAB
> $ gawk 'BEGIN{SYMTAB["foo"]="bar";print SYMTAB["foo"]}'
> gawk: cmd. line:1: fatal: cannot assign to arbitrary elements of SYMTAB
> $ gawk 'BEGIN{SYMTAB["foo"]="bar";print foo;print SYMTAB["foo"]}'
> bar
> bar



reply via email to

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