From: Aaron Harsh Date: 2001-08-17T05:56:58+09:00 Subject: [ruby-talk:19918] Why the " * volatile " declarations in the C source? Sorry in advance if this is a stupid question, but... I noticed a lot of pointers in the C source being declared as '* volatile'. For example, this declaration at the top of rb_eval in eval.c: NODE * volatile node = n; I would have just ignored them if they'd been 'volatile NODE * node', but 'NODE * volatile' is pretty interesting. No one on #ruby-lang at the time was quite sure, so I thought I'd bug c.l.r. Here are my guesses so far, and my reasons for rejecting them: 1) The garbage collector could conceivably move an object, and would need to modify any pointers to the old location. This one seemed promising, but I couldn't see any compaction in the GC code, and the #ruby-lang'ers confirmed that Ruby's GC doesn't compact 2) The 'volatile' thing might just be a trick to make sure the pointer is stored on the stack (rather than a register), so that the GC sees it during marking. But it seems a lot more straightforward to just scan through the registers during mark (rather than put a 'volatile' definition in every place where a variable could be the only pointer to an object). So I'm stumped, and I'm losing sleep over this. What's the real reason?