GCC 4.9.0 公布,提升 C++11 和 C++14 特性
from :http://www.oschina.net/news/51084/gcc-4-9-0
GCC 4.9.0 公布,此版本号是个主要版本号更新,包含了 GCC 4.8.x 系列和之前的 GCC 版本号都没有的新特性,新特性很之多。下载地址:http://gcc.gnu.org/mirrors.html
警告
移除 mudflap 执行时检查器,mudflap 选项保留,但没有不论什么效果.
对一些非常多老的系统和一些不维护的平台的支持在 4.9 版本号中声明为过世的,下一个版本号将永久删除,比如 Solaris 9
很多其它移植到 GCC 4.9 的信息请參考 移植指南
一般优化器改进
AddressSanitizer, a fast memory error detector, is now available on ARM.
UndefinedBehaviorSanitizer (ubsan), a fast undefined behavior detector, has been added and can be enabled via
-fsanitize=undefined.
Various computations will be instrumented to detect undefined behavior at runtime. UndefinedBehaviorSanitizer is currently available for the C and C++ languages.Link-time optimization (LTO) improvements:Memory usage building Firefox with debug enabled was reduced from 15GB to 3.5GB; link time from 1700 seconds to 350 seconds.
Type merging was rewritten. The new implementation is significantly faster and uses less memory.
Better partitioning algorithm resulting in less streaming during link time.
Early removal of virtual methods reduces the size of object files and improves link-time memory usage and compile time.
Function bodies are now loaded on-demand and released early improving overall memory usage at link time.
C++ hidden keyed methods can now be optimized out.
When using a linker plugin, compiling with the
-fltooption now generates slim objects files (.o)
which only contain intermediate language representation for LTO. Use-ffat-lto-objectsto create
files which contain additionally the object code. To generate static libraries suitable for LTO processing, usegcc-arand
gcc-ranlib; to list symbols from a slim object file usegcc-nm.
(Requires thatar,ranlibandnmhave
been compiled with plugin support.)
Inter-procedural optimization improvements:
New type inheritance analysis module improving devirtualization. Devirtualization now takes into account anonymous name-spaces and the C++11
finalkeyword.New speculative devirtualization pass (controlled by
-fdevirtualize-speculatively.Calls that were speculatively made direct are turned back to indirect where direct call is not cheaper.
Local aliases are introduced for symbols that are known to be semantically equivalent across shared libraries improving dynamic linking times.
Feedback directed optimization improvements:
Profiling of programs using C++ inline functions is now more reliable.
New time profiling determines typical order in which functions are executed.
A new function reordering pass (controlled by
-freorder-functions) significantly reduces startup time of large applications.
Until binutils support is completed, it is effective only with link-time optimization.Feedback driven indirect call removal and devirtualization now handle cross-module calls when link-time optimization is enabled.
新语言和语音特性改进
Version 4.0 of the OpenMP specification is now supported for the C and C++ compilers. The new
-fopenmp-simdoption
can be used to enable OpenMP's SIMD directives, while ignoring other OpenMP directives. The new-fsimd-cost-model=option
permits to tune the vectorization cost model for loops annotated with OpenMP and Cilk Plussimddirectives;-Wopenmp-simdwarns
when the current costmodel overrides simd directives set by the user.The
-Wdate-timeoption has been added for the C, C++ and Fortran compilers, which warns when the__DATE__,
or
__TIME____TIMESTAMP__macros are used. Those macros might prevent bit-wise-identical reproducible compilations.
Ada
GNAT switched to Ada 2012 instead of Ada 2005 by default.
C family
Support for colorizing diagnostics emitted by GCC has been added. The
-fdiagnostics-color=autowill
enable it when outputting to terminals,-fdiagnostics-color=alwaysunconditionally. TheGCC_COLORSenvironment
variable can be used to customize the colors or disable coloring. IfGCC_COLORSvariable is present in the
environment, the default is-fdiagnostics-color=auto, otherwise-fdiagnostics-color=never.
Sample diagnostics output:$ g++ -fdiagnostics-color=always -S -Wall test.C test.C: In function ‘int foo()’: test.C:1:14: warning: no return statement in function returning non-void [-Wreturn-type]
int foo () { } ^
test.C:2:46: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) instantiating ‘struct X<100>’
template <int N> struct X { static const int value = X<N-1>::value; }; template struct X<1000>; ^
test.C:2:46: recursively required from ‘const int X<999>::value’ test.C:2:46: required from ‘const int X<1000>::value’ test.C:2:88: required from here test.C:2:46: error: incomplete type ‘X<100>’ used in nested name specifierWith the new
#pragma, the user can assert that there are no loop-carried dependencies which would prevent concurrent execution of consecutive iterations using SIMD (single instruction multiple data) instructions.
GCC ivdepSupport for Cilk Plus has been added and can be enabled with the
-fcilkplusoption.
Cilk Plus is an extension to the C and C++ languages to support data and task parallelism. The present implementation follows ABI version 1.2; all features but_Cilk_forhave
been implemented.
C
ISO C11 atomics (the
_Atomictype specifier and qualifier and the<stdatomic.h>header)
are now supported.ISO C11 generic selections (
_Generickeyword) are now supported.ISO C11 thread-local storage (
_Thread_local, similar to GNU C__thread)
is now supported.ISO C11 support is now at a similar level of completeness to ISO C99 support: substantially complete modulo bugs, extended identifiers (supported except for corner cases when
-fextended-identifiersis
used), floating-point issues (mainly but not entirely relating to optional C99 features from Annexes F and G) and the optional Annexes K (Bounds-checking interfaces) and L (Analyzability).A new C extension
__auto_typeprovides a subset of the functionality of C++11autoin
GNU C.
C++
The G++ implementation of C++1y return type deduction for normal functions has been updated to conform to N3638,
the proposal accepted into the working paper. Most notably, it adds decltype(auto) for getting decltype semantics rather than the template argument deduction semantics
of plain auto:int& f();
auto i1 = f(); // int
decltype(auto) i2 = f(); // int&G++ supports C++1y lambda capture initializers:
[x = 42]{ ... };Actually, they have been accepted since GCC 4.5, but now the compiler doesn't warn about them with -std=c++1y, and supports parenthesized and brace-enclosed initializers as well.
G++ supports C++1y variable length arrays. G++ has supported GNU/C99-style VLAs for a long time, but now additionally
supports initializers and lambda capture by reference. In C++1y mode G++ will complain about VLA uses that are not permitted by the draft standard, such as forming a pointer to VLA type or applying sizeof to
a VLA variable. Note that it now appears that VLAs will not be part of C++14, but will be part of a separate document and then perhaps C++17.void f(int n) {
int a[n] = { 1, 2, 3 }; // throws std::bad_array_length if n < 3
[&a]{ for (int i : a) { cout << i << endl; } }();
&a; // error, taking address of VLA
}G++ supports the C++1y [[deprecated]] attribute modulo bugs in the underlying [[gnu::deprecated]] attribute. Classes
and functions can be marked deprecated and a diagnostic message added:class A;
int bar(int n);
#if __cplusplus > 201103
class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
[[deprecated("bar is unsafe; use foo() instead")]]
int bar(int n); int foo(int n);
class B;
#endif
A aa; // warning: 'A' is deprecated : A is deprecated in C++14; Use B instead
int j = bar(2); // warning: 'int bar(int)' is deprecated : bar is unsafe; use foo() insteadG++ supports C++1y digit separators. Long numeric literals can be subdivided with a single quote ' to enhance readability:
int i = 1048576;
int j = 1'048'576;
int k = 0x10'0000;
int m = 0'004'000'000;
int n = 0b0001'0000'0000'0000'0000'0000; double x = 1.602'176'565e-19;
double y = 1.602'176'565e-1'9;G++ supports C++1y polymorphic lambdas.
// a functional object that will increment any type
auto incr = [](auto x) { return x++; };
Runtime Library (libstdc++)
Improved support for C++11, including:
support for
<regex>;The associative containers in
<map>and<set>and
the unordered associative containers in<unordered_map>and<unordered_set>
meet the allocator-aware container requirements;
Improved experimental support for the upcoming ISO C++ standard, C++14, including:
fixing
constexprmember functions withoutconst;implementation of the
std::exchange()utility function;addressing tuples by type;
implemention of
std::make_unique;implemention of
std::shared_lock;making
std::result_ofSFINAE-friendly;adding
operator()tointegral_constant;adding user-defined literals for standard library types
std::basic_string,std::chrono::duration,
andstd::complex;adding two range overloads to non-modifying sequence oprations
std::equalandstd::mismatch;adding IO manipulators for quoted strings;
adding
constexprmembers to<utility>,
<complex>,<chrono>,
and some containers;adding compile-time
std::integer_sequence;adding cleaner transformation traits;
making
<functional>s operator functors easier to use and more generic;
An implementation of
std::experimental::optional.An implementation of
std::experimental::string_view.The non-standard function
std::copy_exceptionhas been deprecated and will be removed in a future version.std::make_exception_ptr
should be used instead.
Fortran
Compatibility notice:
Note that the argument passing ABI has changed for scalar dummy arguments
of typeINTEGER,REAL,
COMPLEXandLOGICAL,
which have both theVALUEand theOPTIONALattribute.Due to the support of finalization, the virtual table associated with polymorphic variables has changed. Therefore, code containing
CLASSshould
be recompiled, including all files which define derived types involved in the type definition used by polymorphic variables. (Note: Due to the incremented module version, trying to mix old code with new code will usually give an
error message.)Module files: The version of the module files (
.mod) has been incremented; additionally, module files are now
compressed. FortranMODULEs compiled by earlier GCC versions have to be recompiled, when they areUSEd
by files compiled with GCC 4.9, because GCC 4.9 is not able to read.modfiles of earlier GCC versions;
attempting to do so gives an error message. Note: The ABI of the produced assembler data itself has not changed: object files and libraries are fully compatible to older versions. (Except for the next items.)ABI changes:
GNU Fortran no longer deallocates allocatable variables or allocatable components of variables declared in the main program. Since Fortran 2008, the standard explicitly states that variables declared in the Fortran main program automatically
have theSAVEattribute.When opening files, the close-on-exec flag is set if the system supports such a feature. This is generally considered good practice these days, but if there is a need to pass file descriptors to child processes the parent process must now
remember to clear the close-on-exec flag by callingfcntl(), e.g. viaISO_C_BINDING,
before executing the child process.
The deprecated command-line option
-fno-whole-filehas been removed. (-fwhole-fileis
the default since GCC 4.6.)-fwhole-file/-fno-whole-file
continue to be accepted but do not influence the code generation.The compiler no longer unconditionally warns about
DOloops with zero iterations. This warning is now controlled
by the-Wzerotripsoption, which is implied by-Wall.The new
NO_ARG_CHECKattribute of the!GCC$directive can
be used to disable the type-kind-rank (TKR) argument check for a dummy argument. The feature is similar to ISO/IEC TS 29133:2012'sTYPE(*),
except that it additionally also disables the rank check. Variables withNO_ARG_CHECKhave to be dummy
arguments and may only be used as argument toISO_C_BINDING'sC_LOC
and as actual argument to anotherNO_ARG_CHECKdummy argument; also the other constraints ofTYPE(*)apply.
The dummy arguments should be declared as scalar or assumed-size variable of typetype(*)(recommended)
– or of typeinteger,real,complex
orlogical. WithNO_ARG_CHECK,
a pointer to the data without further type or shape information is passed, similar to C'svoid*. Note that
also TS 29113'stype(*),dimension(..)accepts arguments of any type and rank; contrary toNO_ARG_CHECKassumed-rank
arguments pass an array descriptor which contains the array shape and stride of the argument.-
Finalization is now supported. Note that finalization is currently only done for a subset of the situations in which it should occur.
Experimental support for scalar character components with deferred length (i.e. allocatable string length) in derived types has been added. (Deferred-length character variables are supported since
GCC 4.6.)
-
When
STOPorERRORis used to terminate the execution and any exception (but inexact) is signaling, a warning is printed to
STOPERROR_UNIT,
indicating which exceptions are signaling. The-ffpe-summary=command-line
option can be used to fine-tune for which exception the warning should be shown.Rounding on input (
READ) is now handled on systems wherestrtodhonours
the rounding mode. (For output, rounding is supported since GCC 4.5.) Note that for input, thecompatiblerounding
mode is handled asnearest(i.e., for a tie, rounding to an even last significant [cf. IEC 60559:1989]
– whilecompatiblerounds away from zero for a tie).
Go
GCC 4.9 provides a complete implementation of the Go 1.2.1 release.
新平台支持
AArch64
The ARMv8-A crypto and CRC instructions are now supported through intrinsics. These are enabled when the architecture supports these and are available through the
-march=armv8-a+crc
and-march=armv8-a+cryptooptions.Initial support for ILP32 has now been added to the compiler. This is now available through the command line option
-mabi=ilp32.
Support for ILP32 is considered experimental as the ABI specification is still beta.Coverage of more of the ISA including the SIMD extensions has been added. The Advanced SIMD intrinsics have also been improved.
The new local register allocator (LRA) is now on by default for the AArch64 backend.
The REE (Redundant extension elimination) pass has now been enabled by default for the AArch64 backend.
Tuning for the Cortex-A53 and Cortex-A57 has been improved.
Initial big.LITTLE tuning support for the combination of Cortex-A57 and Cortex-A53 was added through the
-mcpu=cortex-a57.cortex-a53option.
A number of structural changes have been made to both the ARM and AArch64 backends to facilitate improved code-generation.
ARM
Use of Advanced SIMD (Neon) for 64-bit scalar computations has been disabled by default. This was found to generate better code in only a small number of cases. It can be turned back on with the
option.
-mneon-for-64bitsFurther support for the ARMv8-A architecture, notably implementing the restriction around IT blocks in the Thumb32 instruction set has been added. The
-mrestrict-itoption
can be used with-march=armv7-aor the-march=armv7veoptions
to make code generation fully compatible with the deprecated instructions in ARMv8-A.Support has now been added for the ARMv7ve variant of the architecture. This can be used by the
-march=armv7veoption.The ARMv8-A crypto and CRC instructions are now supported through intrinsics and are available through the
-march=armv8-a+crc
andmfpu=crypto-neon-fp-armv8options.LRA is now on by default for the ARM target. This can be turned off using the
-mno-lraoption. This option is
purely transitionary command line option and will be removed in a future release. We are interested in any bug reports regarding functional and performance regressions with LRA.A new option
-mslow-flash-datato improve performance of programs fetching data on slow flash memory has now
been introduced for the ARMv7-M profile cores.A new option
-mpic-data-is-text-relativefor targets that allows data segments to be relative to text segments
has been added. This is on by default for all targets except VxWorks RTP.A number of infrastructural changes have been made to both the ARM and AArch64 backends to facilitate improved code-generation.
GCC now supports Cortex-A12 and the Cortex-R7 through the
-mcpu=cortex-a12and-mcpu=cortex-r7options.GCC now has tuning for the Cortex-A57 and Cortex-A53 through the
-mcpu=cortex-a57and-mcpu=cortex-a53options.
Initial big.LITTLE tuning support for the combination of Cortex-A57 and Cortex-A53 was added through the
-mcpu=cortex-a57.cortex-a53option. Similar support was added for the combination of Cortex-A15 and Cortex-A7 through the
-mcpu=cortex-a15.cortex-a7option.
Further performance optimizations for the Cortex-A15 and the Cortex-M4 have been added.
A number of code generation improvements for Thumb2 to reduce code size when compiling for the M-profile processors.
IA-32/x86-64
-mfpmath=sseis now implied by-ffast-mathon
all targets where SSE2 is supported.Intel AVX-512 support was added to GCC. That includes inline assembly support, new registers and extending existing ones, new intrinsics (covered by corresponding testsuite), and basic autovectorization. AVX-512 instructions are available via
the following GCC switches: AVX-512 foundation instructions:-mavx512f, AVX-512 prefetch instructions:-mavx512pf,
AVX-512 exponential and reciprocal instructions:-mavx512er, AVX-512 conflict detection instructions:-mavx512cd.It is now possible to call x86 intrinsics from select functions in a file that are tagged with the corresponding target attribute without having to compile the entire file with the
-mxxxoption.
This improves the usability of x86 intrinsics and is particularly useful when doing Function
Multiversioning.GCC now supports the new Intel microarchitecture named Silvermont through
-march=silvermont.GCC now supports the new Intel microarchitecture named Broadwell through
-march=broadwell.Optimizing for other Intel microarchitectures have been renamed to
-march=nehalem,westmere,
sandybridge,ivybridge,
haswell,bonnell.-march=generichas been retuned for better support of Intel core and AMD Bulldozer architectures. Performance
of AMD K7, K8, Intel Pentium-M, and Pentium4 based CPUs is no longer considered important for generic.-mtune=intelcan now be used to generate code running well on the most current Intel processors, which are Haswell
and Silvermont for GCC 4.9.Support to encode 32-bit assembly instructions in 16-bit format is now available through the
-m16command-line
option.Better inlining of
memcpyandmemsetthat
is aware of value ranges and produces shorter alignment prologues.-mno-accumulate-outgoing-argsis now honored when unwind information is output. Argument accumulation is also
now turned off for portions of programs optimized for size.Support for new AMD family 15h processors (Excavator core) is now available through the
-march=bdver4and
-mtune=bdver4options.
MSP430
A new command-line option
-mcpu=has been added to the MSP430 backend. This option is used to specify the ISA to
be used. Accepted values aremsp430(the default),msp430xandmsp430xv2.
The ISA is no longer deduced from the-mmcu=option as there are far too many different MCU names. The-mmcu=option
is still supported, and this is still used to select linker scripts and generate a C preprocessor symbol that will be recognised by themsp430.hheader
file.
NDS32
A new nds32 port supports the 32-bit architecture from Andes Technology Corporation.
The port provides initial support for the V2, V3, V3m instruction set architectures.
Nios II
A port for the Altera Nios II has been contributed by Mentor Graphics.
PowerPC / PowerPC64 / RS6000
GCC now supports Power ISA 2.07, which includes support for Hardware Transactional Memory (HTM), Quadword atomics and several VMX and VSX additions, including Crypto, 64-bit integer, 128-bit integer and decimal integer operations.
Support for the POWER8 processor is now available through the
-mcpu=power8and-mtune=power8options.The libitm library has been modified to add a HTM fastpath that automatically uses POWER's HTM hardware instructions when it is executing on a HTM enabled processor.
Support for the new powerpc64le-linux platform has been added. It defaults to generating code that conforms to the ELFV2 ABI.
S/390, System z
Support for the Transactional Execution Facility included with the IBM zEnterprise zEC12 processor has been added. A set of GCC style builtins as well as XLC style builtins are provided. The builtins are enabled by default when using the
-march=zEC12option
but can explicitly be disabled with-mno-htm. Using the GCC builtins also libitm supports hardware
transactions on S/390.The hotpatch features allows to prepare functions for hotpatching. A certain amount of bytes is reserved before the function entry label plus a NOP is inserted at its very beginning to implement a backward jump when applying a patch. The
feature can either be enabled via command line option-mhotpatchfor a compilation unit or can be enabled
per function using thehotpatchattribute.The shrink wrap optimization is now supported on S/390 and enabled by default.
A major rework of the routines to determine which registers need to be saved and restored in function prologue/epilogue now allow to use floating point registers as save slots. This will happen for certain leaf function with
-march=z10
or higher.The LRA rtl pass replaces reload by default on S/390.
RX
The port now allows to specify the RX100, RX200, and RX600 processors with the command line options -mcpu=rx100, -mcpu=rx200 and -mcpu=rx600.
SH
Minor improvements to code generated for integer arithmetic and code that involves the T bit.
Added support for the SH2A
clipsandclipu
instructions. The compiler will now try to utilize them for min/max expressions such asmax (-128, min (127, x)).Added support for the
cmp/strinstruction through built-in functions such as__builtin_strlen.
When not optimizing for size, the compiler will now expand calls to e.g.strlenas an inlined sequences which
utilize thecmp/strinstruction.Improved code generated around volatile memory loads and stores.
The option
-mcbranchdihas been deprecated. Specifying it will result in a warning and will not influence code
generation.The option
-mcmpeqdihas been deprecated. Specifying it will result in a warning and will not influence code generation.
具体内容请看发行说明。
GCC 4.9.0 公布,提升 C++11 和 C++14 特性的更多相关文章
- 编译安装GCC 5.2.0
https://blog.atime.me/note/install-gcc-5.2.0-from-source.html 记录编译GCC 5.2.0时遇到的问题和解决方法,以备日后查询. 平时使用的 ...
- Qt on Android: Qt 5.3.0 公布,针对 Android 改进的说明
5月20日本,Qt 官方博客宣布 Qt 5.3.0 公布! 这个版本号聚焦在性能.稳定性和可用性的提升上,与 5.1 / 5.2 相比有非常大提升. 5.3.0 的主要变化: 稳定能.可用性大大提升 ...
- (数据科学学习手札139)geopandas 0.11版本重要新特性一览
本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 大家好我是费老师,就在几天前,geopandas ...
- Solr4.8.0源码分析(11)之Lucene的索引文件(4)
Solr4.8.0源码分析(11)之Lucene的索引文件(4) 1. .dvd和.dvm文件 .dvm是存放了DocValue域的元数据,比如DocValue偏移量. .dvd则存放了DocValu ...
- Asp.Net Core 2.0 项目实战(11) 基于OnActionExecuting全局过滤器,页面操作权限过滤控制到按钮级
1.权限管理 权限管理的基本定义:百度百科. 基于<Asp.Net Core 2.0 项目实战(10) 基于cookie登录授权认证并实现前台会员.后台管理员同时登录>我们做过了登录认证, ...
- gcc 6.2.0/6.3.0/8.2.0 编译安装
参考:http://www.linuxfromscratch.org/blfs/view/stable/general/gcc.html 下载地址在这里:https://ftp.gnu.org/gnu ...
- ubuntu 13.04 编译 安装 升级 gcc 4.9.0 address sanitizer
@ 前记: 最近查一个线上项目的crash,review代码无果,crash几率低,不可在本地环境重现.之后在线上好几个服务器跑valgrind就不crash了.个人猜测可能是跑valgrind后性能 ...
- 【ERROR】while loading shared libraries: /u01/app/oracle/product/11.2.0/lib/libclntsh.so.11.1: cannot
问题: [oracle@mydb]$ lsnrctl status lsnrctl: error while loading shared libraries: /u01/app/oracle/pro ...
- GCC 7.3.0版本编译http-parser-2.1问题
http-paser是一个用c编写的http消息解析器,地址:https://github.com/nodejs/http-parser,目前版本2.9 今天用gcc 7.3.0编译其2.1版本时,编 ...
随机推荐
- Flask: Quickstart解读
Windows 10家庭中文版,Python 3.6.4,Flask 1.0.2 从示例代码说起: from flask import Flask app = Flask(__name__) @app ...
- Win10搜索不能用
使用win10进行搜索时,一直显示win10特色的滚动条,但就是检索不出东西,我的主要是检索不到windows的内容: (个人感觉使用win10检索网页内容不太专业,就关闭了Web搜索) 最后有发现网 ...
- PV操作2011
- Java 泛型和类型安全的容器
使用java SE5之前的容器的一个主要问题就是编译器允许你向容器插入不正确的类型,例如: //: holding/ApplesAndOrangesWithoutGenerics.java // Si ...
- shell 中>/dev/null 2>&1含义
shell中可能经常能看到:>/dev/null 2>&1 命令的结果可以通过%>的形式来定义输出 分解这个组合:“>/dev/null 2>&1” 为五 ...
- MySQL学习笔记:少用Null
在实际编程中,Null容易引起很多问题,例如在Java里NullPointerException猝不及防的空指针异常,因此需要过多的if判断,甚是麻烦. 在MySQL数据库中也要少用Null,尽量保持 ...
- Visual Studio 2017 百度云下载
链接: https://pan.baidu.com/s/1kFjGwyj5HwabvmJKiyLF_g 提取码: 关注公众号[GitHubCN]回复获取 秘钥Enterprise:NJVYC-BM ...
- #JS Regex正则表达式的使用
字符串带的正则表达式相关的方法 1.search() 搜索符合指定正则表达式在目标字符串中的位置 str.search('hello'); //str字符串中查找search字符串,成功返回位置,否则 ...
- 【LOJ】#2028. 「SHOI2016」随机序列
题解 我们发现只有从第一个往后数,用乘号联通的块是有贡献的 为什么,因为后面所有表达式 肯定会有 + ,还会有个-,贡献全都被抵消了 所以我们处理出前缀乘积,然后乘上表达式的方案数 答案就是\(\su ...
- bzoj 1232 [Usaco2008Nov]安慰奶牛cheer
思路:看出跟dfs的顺序有关就很好写了, 对于一棵树来说确定了起点那么访问点的顺序就是dfs序,每个点经过 其度数遍,每条边经过2边, 那么我们将边的权值×2加上两端点的权值跑最小生成树,最后加上一个 ...