It works for cubemaps, but when using with regular texture arrays it should use unbound buffer:
uint counter[];
And CPU must create either worst case buffer size (2K slices for most vendors) or use some sort of dynamic allocation when generating something new with bigger slice count than used so far.