Slashdot Mirror


Examining the User-Reported Issues With Upgrading From GCC 4.7 To 4.8

Nerval's Lobster writes "Developer and editor Jeff Cogswell writes: 'When I set out to review how different compilers generate possibly different assembly code (specifically for vectorized and multicore code), I noticed a possible anomaly when comparing two recent versions of the g++ compiler, 4.7 and 4.8. When I mentioned my concerns, at least one user commented that he also had a codebase that ran fine after compiling with 4.6 and 4.7, but not with 4.8.' So he decided to explore the difference and see if there was a problem between 4.7 and 4.8.1, and found a number of issues, most related to optimization. Does this mean 4.8 is flawed, or that you shouldn't use it? 'Not at all,' he concluded. 'You can certainly use 4.8,' provided you keep in mind the occasional bug in the system."

11 of 148 comments (clear)

  1. Complete waste of time. by Anonymous Coward · · Score: 5, Informative

    Thanks for another worthless uninformative article.

  2. And importantly is your code standards compliant? by queazocotal · · Score: 4, Informative

    Though the code behaves differently with, and without optimisation, and does not work on the new compiler whereas it did on the old,
    this does not mean it is a bug in the compiler.

    GCC, Clang, acc, armcc, icc, msvc, open64, pathcc, suncc, ti, windriver, xlc all do varying optimisations that vary across version, and
    that rely on exact compliance with the C standard. If your code is violating this standard, it risks breaking on upgrade.

    http://developers.slashdot.org/story/13/10/29/2150211/how-your-compiler-can-compromise-application-security
    http://pdos.csail.mit.edu/~xi/papers/stack-sosp13.pdf
    Click on the PDF, and scroll to page 4 for a nice table of optimisations vs compiler and optimisation level.

    _All_ modern compilers do this as part of optimisation.

    GCC 4.2.1 for example, with -o0 (least optimisation) will eliminate if(p+100p)

    This doesn't on first glance seem insane code to check if a buffer will overflow if you put some data into it. However the C standard says that an overflowed
      pointer is undefined, and this means the compiler is free to assume that it never occurs, and it can safely omit the result of the test.

  3. Duh? by Fwipp · · Score: 5, Informative

    The article basically says:
    "GCC 4.8 includes new optimizations! Because of this, the generated assembly code is different! This might be BAD."

    Like, duh? Do you expect optimizations to somehow produce the same assembly as before, except magically faster?

    The linked "bug" is here: http://stackoverflow.com/questions/19350097/pre-calculating-in-gcc-4-8-c11 - which says, "Hey, this certain optimization isn't on by default anymore?" And to which the answer is, "Yeah, due to changes in C++11, you're supposed to explicitly flag that you want that optimization in your code."

    So, yeah. Total non-story.

  4. Rubbish summary, very little in the blog by gnasher719 · · Score: 5, Informative

    He actually observed that different assembler code was generated - well how do you think can you generate _faster_ assembler code without generating _different_ assembler code?

    The article does _not_ make any claim that any code would be working incorrectly, or give different results. The article _doesn't_ examine any user-reported issues. So on two accounts, the article summary is totally wrong.

    1. Re:Rubbish summary, very little in the blog by Megol · · Score: 5, Informative
      Not assembler code - assembly code. Assembler = compiler for assembly code.

      (Pet peeve - sorry)

  5. 4.8.1 has bugs, some of these have been fixed by inglorion_on_the_net · · Score: 4, Informative

    Having been somewhat involved in the migration of a lot of C++ code from older versions of gcc to gcc 4.8.1, I can tell you that 4.8.1 definitely has bugs, in particular with -ftree-slp-vectorize. This doesn't appear to be a huge problem in that almost all the (correct) C++ code we threw at the compiler produced good compiler output, meaning that the quality of the compiler is very good overall. If you do find a bug, and you have some code that reproduces the problem, file a bug report, and the gcc devs will fix the problem. At any rate, gcc 4.8.2 has been out for a number of months now, so if you're still on 4.8.1, you may want to upgrade.

    --
    Please correct me if I got my facts wrong.
  6. cmpxchg8b by little1973 · · Score: 1, Informative

    I haven't tried this with the latest version by even a version 4.x GCC cannot generate inline code with the 8 bytes version of cmpxchg with 32bit code. Doing this in a function is OK.

    I think the problem is that this instruction almost takes up all of the registers and GCC cannot cope with this if you want to do it inline.

    cmpxchg8b is useful for lock-free code.

    --
    Government cannot make man richer, but it can make him poorer. - Ludwig von Mises
  7. Re:Affects me by cheesybagel · · Score: 2, Informative

    Run your program under valgrind and fix the damned bugs.

  8. Re:Keep in mind the occasional bug in the system? by 0123456 · · Score: 3, Informative

    Yeah, most of the bugs that initially looked like compiler bugs turned out to be code bugs, or undefined behaviour. I don't remember which real compiler bugs we ran into, but they were real bugs that the vendor admitted to and eventually fixed.

  9. Re:And importantly is your code standards complian by Muad'Dave · · Score: 4, Informative

    << LIke This >>

    Hint: the trailing ';' is not optional.

    --
    Tiller's Rule: Never use a word in written form that you've only heard and never read. You will end up looking foolish.
  10. Re:Keep in mind the occasional bug in the system? by AdamInParadise · · Score: 3, Informative

    Not true. Check this out: CompCert, a formally proven C compiler (i.e. 100% perfect).

    And you can use it today, for free (GPL), on real programs.

    --
    Nobox: Only simple products.