GCC 6 Just Around The Corner |
Written by Alex Armstrong |
Monday, 29 February 2016 |
GCC 6 is set to be released in March. What is new in this venerable compiler collection?
You might think that after being worked on for so long there would be nothing much left to do, but a compiler is a complex and difficult thing to implement and there is always something that can be done better. Over time GCC has added so many warnings for possible coding problems that it has almost moved into the area of becoming a code analyser. But wait what else is a compiler? The latest warning that has been implemented would have saved Apple from the SSL bug - I TOLD You Gotos Are Dangerous! - caused by incorrect groupings of gotos and ifs. They were indented as if the goto was part of the if block, but it wasn't. GCC 6 checks the syntax and compares it against the indenting and warns the programmer if the indenting isn't appropriate. It begs the question of why, if the correct indenting can be derived from the syntax, not simply get the compiler to enforce it? Perhaps this is too far down the road of becoming Python. Or perhaps it is more something an IDE would do. It will also flag silly Boolean conditionals such as comparing an object to itself, duplicate subclauses and so on. It will now also flag undefined behavior if you left shift a negative value. Although it is arguable that C/C++ should really not be as vague on what happens during such a shift. The whole notion of undefined behaviour and its use in compiler optimization is crazy. If the code is legal it should have a single semantic interpretation. Another improvement is in the detection and flagging of null pointer dereferencing. Somehow in this case flagging a warning doesn't seem to be sufficient. Interestingly, general error reporting has also been improved to indicate a range where the error might be and to indicate where in a string an error might be. Also new are "fix-it" hints which attempt to point at the part of the code that probably has to be changed. Finally, a sort of post-compile Intellisense attempt to flag misspelled field names and suggest alternatives. The new features listed, are slightly esoteric, which is in keeping with the maturity of the compiler. We have better support for OpenMP for parallel programming and you can now specify the storage order "endian-ness" of fields in a structure and the compiler will compensate if the architecture of the target does things the other way round. A real blast from the past is the ability to work with a segmented memory architecture. The x86 processor line supports segmentation, but most modern programming environments since the 386 use paging and a linear virtual address space. Even so, operating systems have to manipulate segment registers and until now it has been necessary to resort to assembler to do this. Now you can declare variables relative to a particular segment. Finally C++ now defaults to C++ 14 and there is experimental support for some C++ 17 features. GCC is a large system and there are also lots of optimizations and improvements - check out the documentation for a full list.
More InformationGCC 6 Release Series Changes, New Features, and Fixes Related ArticlesGNU Compiler Collection 5.1 Released GNU Manifesto Published Thirty Years Ago GCC Gets An Award From ACM And A Blast From Linus I TOLD You Gotos Are Dangerous!
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, Facebook, Google+ or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
Last Updated ( Tuesday, 01 March 2016 ) |