Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And, yet, people still try to use it for that. So it's worth pointing out that it doesn't work.

I think volatile in general is pretty useless, and it'd be better to replace it with atomic style functions:

    x = volatile_read(&v);
    y = use(x);
    volatile_write(&y);
Which is both clearer about what's going on, and doesn't cause optimization barriers to happen everywhere, just around the specific loads and stores you care about.


Volatile is for memory-mapped IO. It's not particularly useful anywhere else.


Thank you for repeating me again. Though it's not even what I want then. I think the only time I've wanted volatile as is currently specified was around setjmp/longjmp -- and I think I'd prefer that setjmp/longjmp were specified in a less error prone way.

If you're paying attention to the standards community, what I'm wishing for was mostly sketched out in ISO/IEC TR 18037, section 6. (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: