Volatiles are often miscompiled
Volatiles are often miscompiled
Thought you guys might be interested in this: http://www.cs.utah.edu/~regehr/papers/e ... eprint.pdf.
- xenos
- Member
- Posts: 1118
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Volatiles are often miscompiled
A paper from 2008 is not quite up to date with current compilers and standards, but still interesting to read and certainly good to know. One should keep this in mind when searching for bugs with volatile variables, and double check the compiler output in that case.
Re: Volatiles are often miscompiled
Would you care to elaborate on how exactly it's not up to date?XenOS wrote:A paper from 2008 is not quite up to date with current compilers and standards, but still interesting to read and certainly good to know. One should keep this in mind when searching for bugs with volatile variables, and double check the compiler output in that case.
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: Volatiles are often miscompiled
Check the versions of the compilers used in the paper vs. current versions of the same compilers.alexfru wrote:Would you care to elaborate on how exactly it's not up to date?XenOS wrote:...
XenOS is right that it's something we need to look out for in specific circumstances (code not doing what we expect with volatile variables) but this is not likely to cause many bugs after *6* years of updates to compilers.
- Monk
Re: Volatiles are often miscompiled
Volatile wasn't exactly new in '08. It was in the original K&R C released in 1978. If the bugs hadn't been fixed in the 30 years previous, they likely weren't fixed in the 6 years following. That is, unless this paper brought the bugs to compiler devs' attention. But even then, I would guess the reason they lasted 30 years probably had something to do with the difficulty in fixing them, which would increase the likelihood they still aren't fixed.XenOS wrote:A paper from 2008 is not quite up to date with current compilers and standards, but still interesting to read and certainly good to know. One should keep this in mind when searching for bugs with volatile variables, and double check the compiler output in that case.
You have to admit, it's pretty astounding that after 30 years of development (of the technology/methods, not the compilers themselves), not a single compiler got it right.
Re: Volatiles are often miscompiled
Compiler versions aren't of much relevance, they aren't definitive. The main question is about what has changed in the language standard(s) and which version of the standard which compiler supports. Since 2008 there's been only one standard update (C++03 -> C++11 and C99 -> C11). It would be nice to hear not just that the paper is somewhat outdated, but how, it shouldn't be a huge difference (a paragraph perhaps, maybe a little more?), right?tjmonk15 wrote:Check the versions of the compilers used in the paper vs. current versions of the same compilers.alexfru wrote:Would you care to elaborate on how exactly it's not up to date?XenOS wrote:...
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Volatiles are often miscompiled
Then you didn't properly read what the paper said itself:Compiler versions aren't of much relevance
because, as of this writing, no release incorporates fixes to all of the bugs we reported. (...) Our experiment is ongoing and we expect that within the
foreseeable future, LLVM - GCC will be effectively free of volatile and functional bugs for the programs emitted by randprog.
Re: Volatiles are often miscompiled
Oh but they are. Upgrading is a cost/benefit question for many non-hobby projects.alexfru wrote:Compiler versions aren't of much relevance, they aren't definitive.
Standards are fairly meaningless unless they're adopted. I use ANSI C so C99 and C11 have absolutely no meaning to me and I'm not alone.alexfru wrote: The main question is about what has changed in the language standard(s) and which version of the standard which compiler supports. Since 2008 there's been only one standard update (C++03 -> C++11 and C99 -> C11).
As someone who has implemented an ISO standard compliant programming language, I'll say that standards are created for many reasons, many of which are non-technical.
Every universe of discourse has its logical structure --- S. K. Langer.
- xenos
- Member
- Posts: 1118
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Volatiles are often miscompiled
Exactly. Those compiler versions are really outdated. And even if these bugs existed for 30 years, they were discovered, pointed out in this article and reported:tjmonk15 wrote:Check the versions of the compilers used in the paper vs. current versions of the same compilers.alexfru wrote:Would you care to elaborate on how exactly it's not up to date?
Combuster wrote:Then you didn't properly read what the paper said itself:Compiler versions aren't of much relevancebecause, as of this writing, no release incorporates fixes to all of the bugs we reported. (...) Our experiment is ongoing and we expect that within the
foreseeable future, LLVM - GCC will be effectively free of volatile and functional bugs for the programs emitted by randprog.
Re: Volatiles are often miscompiled
Wow.bwat wrote:Standards are fairly meaningless unless they're adopted. I use ANSI C so C99 and C11 have absolutely no meaning to me and I'm not alone.
ANSI is just the American standards institute. The International Standards Organisation (ISO) produces documents called ISO9899 and ISO14882, which describe C and C++ in their international variants which have been the norm since 1989. That's where C99 and C11 come from - C99 is short for ISO9899:1999 and C11 is short for ISO9899:2011.
That's a pretty ignorant stance to have. Try to at least think outside of the US-centered box that you currently live in.
Re: Volatiles are often miscompiled
Hi,
Note that I'm mostly the same. I mostly learnt C from "The C Programming Language (second edition)", and haven't really bothered learning anything that was added to C since (excluding my flagrant abuse of "//" for single line comments).
Maybe one day they're release a third edition of this book, and programmers will start learning C11 (and ignore all versions of C created after that)..
Cheers,
Brendan
It has nothing to do with geography or standard bodies (e.g. ANSI vs. ISO); and everything to do with history. Basically; bwat prefers "old" and doesn't like "new" (and doesn't care about which standard body was responsible for "old").Candy wrote:ANSI is just the American standards institute. The International Standards Organisation (ISO) produces documents called ISO9899 and ISO14882, which describe C and C++ in their international variants which have been the norm since 1989. That's where C99 and C11 come from - C99 is short for ISO9899:1999 and C11 is short for ISO9899:2011.bwat wrote:Standards are fairly meaningless unless they're adopted. I use ANSI C so C99 and C11 have absolutely no meaning to me and I'm not alone.
That's a pretty ignorant stance to have. Try to at least think outside of the US-centered box that you currently live in.
Note that I'm mostly the same. I mostly learnt C from "The C Programming Language (second edition)", and haven't really bothered learning anything that was added to C since (excluding my flagrant abuse of "//" for single line comments).
Maybe one day they're release a third edition of this book, and programmers will start learning C11 (and ignore all versions of C created after that)..
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.