This was a bug in 4.0-4.2. This was fixed in 4.3 :
ddd. Fixed several bugs that caused `declare -g' to not set the right global variables or to misbehave when declaring global indexed arrays.
Here is the result at 4.3, where they behave identically:
$ echo $BASH_VERSION 4.3.11(1)-release $ unset x; declare -px; function f() { declare -A -gx; x[10]=100; }; f; declare -px; bash: declare: x: not found declare -A x='([10]="100" )' $ unset x; declare -px; function f() { declare -A -gx=(); x[10]=100; }; f; declare -px; bash: declare: x: not found declare -A x='([10]="100" )'
source share