I remember one time during compilers class I tried to figure out the largest prime number in the denominator that GCC would replace with multiplication and bit shifts. I got up to a number in five digits and stopped counting. Just goes to show the amount of work that goes into compilers and the importance of speed for some program writers.
Yet more bonus points if you implement a way to correlate (roughly) the assembly code with the corresponding C++ code. Like, when you select lines in the C++ code, it highlights the corresponding assembly instructions. Not trivial, especially at high optimization levels.
Actually, it's not that difficult. Get GCC to generate DWARF [debugging] information, and then use that to provide the back-references. (Reference: DWARF 3.0 spec, available at http://dwarfstd.org/doc/Dwarf3.pdf. See page 92.) This is how GDB does the same.
The output is a little weird (I've had it execute line 56 before line 55, for example) and you do have to be careful, as not all lines translate directly. But it would be at least be a nice starting point. There are even some nice libraries out there that parse this information!
EDIT: Hmm, I just noticed that the source is on Github. If I get some time this weekend I'll try adding support for this.
As a cross-platform developer, I would love to see clang and MSVC as compiler options so that I'm able to compare the various outputs when trying to track down undefined/implementation defined behaviors.
As it stands though, this is a fantastic tool! It's right up there with ideone for me.
What's happening in the signed case? Signed division
and modulo have been redefined in newer C/C++ standards. He talks about writing C but the syntax looks like C++ 11? at least i don't think he means the C "auto" here.
This is great. I often compile with gcc -S but then get swamped by the massive amount of included stdlib stuff and name manging, so it's hard to find my code.
Nice. Please add more GCC versions (3.x and 4.0 through 4.3?) and the most recent clang/clang++ releases! Direct pastebin-style links would also be great.