ID:2126487
 
Not a bug
BYOND Version:511.1350
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 52.0.2743.82
Applies to:Dream Daemon
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
I remember there being a bug report or mention of this, but I can't find it.

Basically, list.len-- is behaving like --list.len when inside the index operators.

mob/Login()
// allocate array
var stuff[10], n

// populate array
for(n in 1 to stuff.len) stuff[n] = n

// "pop from the stack"
for(n in 1 to stuff.len) src << stuff[stuff.len--]

Expected output
10
9
8
7
6
5
4
3
2
1
Actual output
runtime error: list index out of bounds
proc name: Login (/mob/Login)
  source file: StackTest.dm,9
  usr: (src)
  src: Kaiochao (/mob)
  src.loc: null
  call stack:
Kaiochao (/mob): Login()
Workaround
Split it into two lines:
src << stuff[stuff.len]
stuff.len--
Lummox JR resolved issue (Not a bug)
This isn't technically a bug. The list.len-- operation happens before the list index access. As a result, the value of list.len-- points to an index that no longer exists.

This isn't equivalent to list[--list.len], because in that case the index is the new, decremented value of list.len.
I agree, not a bug at all. I'm sure I read about this somewhere, that this is the example of how the post-decrement operator is not the same as the two-line "workaround".
To clarify for anybody who stumbles on this thread later:

list[list.len--] basically compiles to list[(. = list.len;list.len -= 1;return .)] (not actual dm syntax, but you get the idea) the right number is getting passed to list[], but before list[] even runs, the -= 1 part has already ran.

It's the same as if you passed num-- to a proc. if num was equal to 10, the proc would get 10, but by the time the proc ran, the variable num would already be set to 9.

/var/num = 10
/proc/p1()
world << "p1:[global.num]"
p2(global.num--)
world << "p1:[global.num]"
/proc/p2(num)
world << "p2:[global.num]"
world << "p2:[num]"


The output you will get is:
p1:10
p2:9
p2:10
p1:9