If you are developing with C/C++, Clang tools and newer versions of GCC can be quite helpful for checking your code and giving you better warnings and error messages to help avoid bugs. The newer compilers have better optimizations and code generation.
You can easily install the latest-supported Clang and GCC compilers for C, C++, Objective-C, and FORTRAN using
yum on Red Hat Enterprise Linux. These compilers are available as software collections that are typically updated twice a year. The May 2018 update included Clang/LLVM 5 and GCC 7.3, as well as Go and Rust.
If you want your default
gcc to always be GCC 7, or you want
clang to always be in your path, this article shows how to permanently enable a software collection by adding it to the profile (dot files) for your user account. A number of common questions about software collections are also answered.
Continue reading “How to install Clang/LLVM 5 and GCC 7 on RHEL”
(See this article to install GCC 7 on Red Hat Enterprise Linux.)
In C and C++, the cases of a
switch statement are in fact labels, and the
switch is essentially a go to that jumps to the desired label. Since labels do not change the flow of control, one case block falls through to the following case block, unless terminated by a
break, a no return call or similar. In the example below, “
case 1” falls through to “
a = 1;
a = 2;
/* ... */
Continue reading “-Wimplicit-fallthrough in GCC 7”
GCC has a rich set of features designed to help detect many kinds of programming errors. Of particular interest are those that corrupt the memory of a running program and, in some cases, makes it vulnerable to security threats. Since 2006, GCC has provided a solution to detect and prevent a subset of buffer overflows in C and C++ programs. Although it is based on compiler technology, it’s best known under the name Fortify Source derived from the synonymous GNU C Library macro that controls the feature: _FORTIFY_SOURCE. GCC has changed and improved considerably since its 4.1 release in 2006, and with its ability to detect these sorts of errors. GCC 7, in particular, contains a number of enhancements that help detect several new kinds of programming errors in this area. This article provides a brief overview of these new features. For a comprehensive list of all major improvements in GCC 7, please see GCC 7 Changes document.
Continue reading “Memory Error Detection Using GCC”
The next release of the GNU Compiler Collection, GCC 7, is fast approaching, so in this post, I’m going to talk about work I’ve done to make GCC more reliable
Continue reading “Testing… Testing… GCC”