GCC 6.1 发布,新增功能特性

发表于2016-04-28
评论0 7k浏览

想免费获取内部独家PPT资料库?观看行业大牛直播?点击加入腾讯游戏学院游戏程序行业精英群

711501594
  GCC 6.1 发布了,该版本较之前GCC5 新怎了大量的功能特性,默认采用C++14为新的标准,替代了之前的C++98。OpenMP 4.5规范将在本版本中被支持。此外,GCC 6.1 增强了对 C++17 的试验性支持;大大改进了诊断特性,包括位置,位置范围,拼写错误标识符建议,选项名字等等改进;新增了修复提示和一些警告提示。
  完整发布说明,可以在这里查看。C/C++ 语言主要改进记录如下:

一、C family
 · Version 4.5 of the OpenMP specification is now supported in the C and C++ compilers.
 · The C and C++ compilers now support attributes on enumerators. For instance, it is now possible to mark enumerators as deprecated:enum { newval, oldval __attribute__ ((deprecated ("too old")))};
 · Source locations for the C and C++ compilers are now tracked as ranges, rather than just points, making it easier to identify the subexpression of interest within a complicated expression. For example:test.cc: In function 'int test(int, int, foo, int, int)': test.cc:5:16: error: no match for 'operator*' (operand types are 'int' and 'foo') return p + q * r * s + t; ~~^~~ In addition, there is now initial support for precise diagnostic locations within strings:format-strings.c:3:14: warning: field width specifier '*' expects a matching 'int' argument [-Wformat=] printf("%*d"); ^
 · Diagnostics can now contain "fix-it hints", which are displayed in context underneath the relevant source code. For example:fixits.c: In function 'bad_deref': fixits.c:11:13: error: 'ptr' is a pointer; did you mean to use '->'? return ptr.x; ^ ->
 · The C and C++ compilers now offer suggestions for misspelled field names:spellcheck-fields.cc:52:13: error: 'struct s' has no member named 'colour'; did you mean 'color'? return ptr->colour; ^~~~~~
 · New command-line options have been added for the C and C++ compilers:
○ -Wshift-negative-value warns about left shifting a negative value.
○ -Wshift-overflow warns about left shift overflows. This warning is enabled by default. -Wshift-overflow=2 also warns about left-shifting 1 into the sign bit.
○ -Wtautological-compare warns if a self-comparison always evaluates to true or false. This warning is enabled by -Wall.
○ -Wnull-dereference warns if the compiler detects paths that trigger erroneous or undefined behavior due to dereferencing a null pointer. This option is only active when -fdelete-null-pointer-checks is active, which is enabled by optimizations in most targets. The precision of the warnings depends on the optimization options used.
○ -Wduplicated-cond warns about duplicated conditions in an if-else-if chain.
○ -Wmisleading-indentation warns about places where the indentation of the code gives a misleading idea of the block structure of the code to a human reader. For example, given CVE-2014-1266:sslKeyExchange.c: In function 'SSLVerifySignedServerKeyExchange': sslKeyExchange.c:629:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation] if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) ^~ sslKeyExchange.c:631:5: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' goto fail; ^~~~ This warning is enabled by -Wall.
 · The C and C++ compilers now emit saner error messages if merge-conflict markers are present in a source file.test.c:3:1: error: version control conflict marker in file <<<<<<< HEAD ^~~~~~~

二、C
 · It is possible to disable warnings when an initialized field of a structure or a union with side effects is being overridden when using designated initializers via a new warning option -Woverride-init-side-effects.
 · A new type attribute scalar_storage_order applying to structures and unions has been introduced. It specifies the storage order (aka endianness) in memory of scalar fields in structures or unions.

三、C++
 · The default mode has been changed to -std=gnu++14.
 · C++ Concepts are now supported when compiling with -fconcepts.
 · -flifetime-dse is more aggressive in dead-store elimination in situations where a memory store to a location precedes a constructor to the memory location.
 · G++ now supports C++17 fold expressions, u8 character literals, extended static_assert, and nested namespace definitions.
 · G++ now allows constant evaluation for all non-type template arguments.
 · G++ now supports C++ Transactional Memory when compiling with -fgnu-tm.

四、Runtime Library (libstdc++)
 · Extensions to the C++ Library to support mathematical special functions (ISO/IEC 29124:2010), thanks to Edward Smith-Rowland.
 · Experimental support for C++17, including the following new features:
○ std::uncaught_exceptions function (this is also available for -std=gnu++NN modes);
○ new member functions try_emplace and insert_or_assign for unique_key maps;
○ non-member functions std::size, std::empty, and std::data for accessing containers and arrays;
○ std::invoke;
○ std::shared_mutex;
○ std::void_t and std::bool_constant metaprogramming utilities.
Thanks to Ville Voutilainen for contributing many of the C++17 features.
 · An experimental implementation of the File System TS.
 · Experimental support for most features of the second version of the Library Fundamentals TS. This includes polymorphic memory resources and array support in shared_ptr, thanks to Fan You.
 · Some assertions checked by Debug Mode can now also be enabled by _GLIBCXX_ASSERTIONS. The subset of checks enabled by the new macro have less run-time overhead than the full _GLIBCXX_DEBUG checks and don't affect the library ABI, so can be enabled per-translation unit.
 · Timed mutex types are supported on more targets, including Darwin.
 · Improved std::locale support for DragonFly and FreeBSD, thanks to John Marino and Andreas Tobler.

五、libgccjit
 · The driver code is now run in-process within libgccjit, providing a small speed-up of the compilation process.
 · The API has gained entrypoints for
○ timing how long was spent in different parts of code,
○ creating switch statements,
○ allowing unreachable basic blocks in a function, and
○ adding arbitrary command-line options to a compilation.

如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引

游戏学院公众号二维码
腾讯游戏学院
微信公众号

提供更专业的游戏知识学习平台