16 ms·
GCC 6.1 Released
- nhamausi 10y agoHurray for C++14 "by default"
- Filligree 10y agoOh, hooray. I wonder which programs are going to break because of optimizations this time?
- deleted 10y ago[deleted]
- Kristine1975 10y agoSame procedure as every year: Only programs that don't conform to the C/C++ standard. Not counting true compiler bugs of course. Edit: The release notes at https://gcc.gnu.org/gcc-6/changes.html https://gcc.gnu.org/gcc-6/changes.html mention three programs that apparently will break: Value range propagation now assumes that the this pointer of C++ member functions is non-null. This eliminates common null pointer checks but also breaks some non-conforming code-bases (such as Qt-5, Chromium, KDevelop)
- Filligree 10y agoAt least with the C standard, it's theoretically possible to learn it. I'd challenge you to find one person in your company who fully understands the C++ standard.
- pjmlp 10y agoAnd I challenge you to find someone that knows all C rules about UB across all major compilers.
- hellofunk 10y agoTrue dat. C is a smaller language and is possible to know the whole language, but not the whole spectrum of UB. C++ is a vastly larger language it is nearly impossible to know the whole language, but much more likely to understand the spectrum of UB.
- octo_t 10y agoUndefined behaviour is the same across all compilers. The compilers aren't the things which make the behaviour undefined, its the C standard.
- pjmlp 10y agoNo it is not, if you ever tried to write portable C code you should clearly be aware that each C compiler has its own flavor of undefined behavior. The C standard is very generous in terms of undefined behavior freedom.
- dsfuoi 10y agoBy definition made in the C Standard, undefined behavior is: behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements If you're using some other definition, then say so, otherwise your comments make no sense.
- pjmlp 10y agoGiven my-app.c, each C compiler out there will pick a different UB subset and not everything that is defined as UB in the standard. They are free to do that and still be compliant, after all UB means anything goes.
- lorenzhs 10y agoThat compilers may behave differently is exactly the point of UB, if they all had to behave the same it wouldn't be undefined, after all!
- octoploid 10y agoWell, just use -fsanitize=undefined and it will point out (most of) the isuses for you.
- Ace17 10y agoProvided that your test suite properly trigger the execution of tricky parts, in tricky situations (You do have a test suite, right?)
- Kristine1975 10y ago>You do have a test suite, right? Of course I do. I call it "customers".
- pjmlp 10y agoWell, not all C compilers have it.
- easytiger 10y agoStroustroup in his book claims he doesn't fully understand it.
- rleigh 10y agoWell, this is the language where Turing-complete template metaprogramming was "discovered" as an emergent property of the system!
- CyberDildonics 10y agoGiant, complicated, wildly successful.
- jordigh 10y agoOr the D standard, or the Java standard, or the Fortran standard, or the Golang standard... It is the GNU compiler collection, after all. I'm actually particularly excited about a new release of gdc myself. I've been reading Alexandrescu's excellent The D Programming Language, and I think it may be just the better C++ that I always wanted, ahead of Golang and Rust.
- lmm 10y agoGCC has an Ada implementation too - you might (or might not) consider that.
- treehau5 10y agoI think this type of thinking is cynical and unhelpful. We complain that compiler technology is not keeping pace, then when they put in god knows how many hundreds of hours of work improving, we complain when we might have to spend a few to go back through our programs and make sure everything's okay. We want everyone else to do the work for us.
- lmm 10y ago> We complain that compiler technology is not keeping pace Who was complaining about that? > when they put in god knows how many hundreds of hours of work improving, we complain when we might have to spend a few to go back through our programs and make sure everything's okay. We want everyone else to do the work for us. Their whole job is to compile our programs - what else is a compiler good for? I don't know who GCC's users are these days - people who care more about benchmarks than working code? Because that seems to be who they're optimising for. Then again I suppose that's the entirety of C/C++'s market these days.
- dave2000 10y agoAre you saying you have an example of valid c++ code which fails to compile, and that this problem is getting worse, or just that you get unexpected behaviour when write bad code?
- coldpie 10y agoCompiler bugs caused by optimizations aren't at all unheard of. We got bit by one recently: https://bugs.winehq.org/show_bug.cgi?id=38653 https://bugs.winehq.org/show_bug.cgi?id=38653 That said, I agree with treehau5.
- lmm 10y ago"Valid" in that the standard absolutely requires that compilers give them some particular meaning, no matter how rules-lawyery the compiler is? No. "Valid" in the sense that the intent is perfectly obvious to any reader? Yes, plenty. "bad"? No, unless you use the standard as your definition of good/bad.
- ben0x539 10y agoThey're helpfully listed in the release notes! > This eliminates common null pointer checks but also breaks some non-conforming code-bases (such as Qt-5, Chromium, KDevelop)
- jbb555 10y agoWe do seem to have got into a race to make C and C++ compilers less and less useful while still following the letter of the rules (but certainly NOT the spirit).
- Kristine1975 10y agoI think modern C and C++ compilers are very useful. Then again I know that these languages are full of huge pitfalls, so I know what I'm getting into, and when I make a mistake I blame myself, not the compilers. I also use the features of modern C/C++ compilers such as warnings (-Weverything on clang, then turn off those warnings I'm not interested in) and sanitizers (Undefined Behavior Sanitizer, Address Sanitizer).
- wtetzner 10y agoI was under the impression that the whole point of undefined behavior in the spec was to give implementers flexibility. Am I wrong? If not, then it sounds like it's very much in the spirit of the rules.
- jordigh 10y agoThat's implementation-defined behaviour (do something nonstandard and document it) or unspecified behaviour (do something specific and nonstandard but don't have to document it). Undefined behaviour allows the compiler writer to have the code do anything unreliable and unpredictable and not document it. Its purpose is to allow compiler writers to completely ignore the erroneous code that results in UB and not spend effort trying to diagnose it or implement it. Most compilers still make an effort to diagnose some UB anyway, though.
- lmm 10y agoThe original reason was to ensure the standard was compatible with existing compilers (i.e. to leave behaviour which varied between existing compilers unstandardized) and to allow hardware-native behaviour for things like integer overflow and extended shifts, not to allow aggressive optimizations.
- DannyBee 10y agoActually, some: "Type-based alias analysis now disambiguates accesses to different pointers. This improves precision of the alias oracle by about 20-30% on higher-level C++ programs. Programs doing invalid type punning of pointer types may now need -fno-strict-aliasing to work correctly."
- manaskarekar 10y ago>The C++ frontend now defaults to C++14 standard instead of C++98 it has been defaulting to previously Honest question, in production, is this sort of a thing pretty much a non-issue? Edit: Sorry, to be clearer, I meant to ask, effect of stuff like changing defaults between different versions. Perhaps, it is a non-issue because most production code is (/maybe) version locked. Also, a little vague, but out of curiosity, how often do C / C++ shops upgrade to the latest and greatest?
- lmm 10y agoI don't understand the question. Is there a difference between C++14 and C++98? Yes. Are there important features in C++14 that aren't in C++98? Yes. Is there existing code that builds fine under C++98 and will break when compiled under C++14? Almost certainly yes as well.
- lallysingh 10y agoYes, the differences between C++14 and 98 are night-and-day different. Quite a few important language features, and plenty of new libraries (including threading and lambdas). There aren't any (AFAIK) explicit breaks of '98 code in '14. So the theory is that code should compile with the new compiler fine, but you'll likely hit some issues. Check out Scott Meyers book: Effective Modern C++ for the deltas.
- MereInterest 10y agoThere is one break that I know of. `>>` is now parsed as two tokens, and will preferentially mean "close two templates" instead of "right bit shift" in cases of ambiguity.
- slrz 10y agoThere are definitely backwards-incompatible changes in the things that were added since C++98. For one, there's a whole set of new keywords that's going to break any code that used them as identifiers. Then there's a keyword that was re-purposed to do something totally different: in C++, auto used to be a storage duration specifier. In C++11 it is used to indicate type inference. There were also changes that, while not breaking source compatibility, basically required implementations to break binary compatibility going from C++98 to C++11. This in particular resulted in a gigantic mess. With regard to breaking changes the C++ committee is not anywhere near as conservative as the one for C.
- the_mitsuhiko 10y agoWhat happened to 6.0.
- Aissen 10y agoIt was the development version. See "Version Numbering Scheme for GCC 5 and Up" here https://gcc.gnu.org/develop.html https://gcc.gnu.org/develop.html .
- hyperpape 10y agoI'm still confused after reading this. Does this mean that 6.0, 6.1.1, 6.2.1 etc. do not actually name specific code bases that can be downloaded? Or is 6.0 the name of a specific commit in the code?
- Kristine1975 10y agoYou can download snapshots of 6.0 e.g. here: ftp://gd.tuwien.ac.at/gnu/gcc/snapshots/
- geofft 10y agoBetween GCC 4.9 and GCC 5, they made basically the same change Linux made between 2.6.39 and 3.0: they dropped one of the components in the version number. The amount of change between GCC 5, 6, 7, etc. are equivalent to the amount of change between 4.7, 4.8, 4.9, etc. They're also using the version 0 in the second component to indicate prereleases. GCC 6.0.0 was the development version of GCC 6. The release candidate was 6.0.1. The first release of GCC 6, which came out today, is 6.1.0. Then there will be development under the name 6.1.1, and the first bugfix release on the GCC 6 line will be 6.2.0. The amount of change between 6.1.0 and 6.2.0 is equivalent to the amount of change between 4.9.0 and 4.9.1 in the old numbering scheme.
- hyperpape 10y agoThanks for the explanation. I realize this is bikeshedding, but is there a rationale behind using 6.0.1 as a release candidate? I get making major versions less rare, but not sure I get he rest of it.
- jordigh 10y agoI recently compiled a contribution graph (number of lines changed per user) for gcc since 2015 using Mercurial's churn command and a simple revset: http://paste.debian.net/plain/442020 http://paste.debian.net/plain/442020 (I excluded the po files, as that gives one user too much credit, since he just checked in the translations, but didn't write them himself.) This is a rather unusual contribution graph. Most I've seen follow a very stark power law, with one contributor doing over 90% of the work, and the second contributor doing around 5%. This graph shows a lot more collaboration from many people. The development of gcc seems healthier than ever!
- Afforess 10y ago>This is a rather unusual contribution graph. Most I've seen follow a very stark power law, with one contributor doing over 90% of the work, and the second contributor doing around 5%. This graph shows a lot more collaboration from many people. The development of gcc seems healthier than ever! Is it a sign of health (diverse community) or a sign of illness (no active technical lead, outsiders driving development in fragmented directions)? I don't think you can tell just by looking at the graph.
- jordigh 10y agoWith the 2nd most contributions and also the one who wrote the release announcement, it seems that Jakub is the current de-facto leader. The graph suggests that he does not lead alone, though. edit: Upon closer inspection, it appears that Arnaud Charlet is currently the top one because he's committed a lot of Ada code for other people from AdaCore. It would take some teasing out of the GNU changelogs instead of the svn log to figure out who really wrote what. So, looks like Jakub really is the leader.
- brandmeyer 10y agoPerhaps it suggests that the steering committee that GCC has chosen to use is an appropriate governance model for them.
- misframer 10y agoI believe "ian" on that list is Ian Lance Taylor. He's on the Go team and works on gccgo so I think most of his contributions [0] are for the Go compiler. [0] Example commit: https://github.com/gcc-mirror/gcc/commit/b0c0971248103432dd623276227da9cd69a755cf https://github.com/gcc-mirror/gcc/commit/b0c0971248103432dd6...
- cm3 10y agoI've recently had to enable C++11 in a project because a header I use added C++11 features, and it appears that going from C++98 to C++11 makes Clang and G++ considerably slower. Can anybody else confirm this?
- majewsky 10y agoDid you test the --std change in isolation, without your new headers? Some libraries' headers are ridiculously expensive when they make heavy use of templates. My favorite in that regard is Boost::Qi.
- cm3 10y agoHow do I test it in isolation without including and making use it as before (aka no code change in the consumer of the previously C++98 header)?
- jononor 10y agoCheckout the version before you introduced the C++11 header. Alternatively, fix the header to be C++98 compatible (may of course be non-trivial).
- netheril96 10y agoJust compile the previous version that conforms to C++98 with different std flags and do the comparison.
- cm3 10y agoRight, that makes sense. Will do, though once confirmed, I will curse C++1x even more, I guess :).
- cm3 10y agoIs there a difference between -std and --std? I've always used -std=FOO.
- 10y ago
- larozin 10y agoWe get it: > C++ Concepts are now supported when compiling with -fconcepts.
- wyldfire 10y ago> This releases features various improvements in the emitted diagnostics, including improved locations, location ranges, suggestions for misspelled identifiers, option names etc., fix-it hints and a couple of new warnings have been added. Every time I hear about new GCC releases all I can think of is how the compiler wars have clearly inspired lots of new feature development. From the high level it seems like GCC is still catching up with clang. Are there cases where GCC has leapt ahead of clang in some features?
- rawnlq 10y agoThey are ahead with certain experimental features such as Concepts
- mordocai 10y agoI believe the discussion in the other comment thread is correct in that GCC generates better binaries.
- mioelnir 10y agoI always find it amusing that in any 'clang compiles faster, gcc provides better binaries' discussion there are always immediately people chiming in that this is based on old data from gcc 4.9. But clang supposedly hasn't improved its binaries in all that time? Unless you target a feature or cpu architecture that only one of them supports, it is close to a coin toss nowadays which compiler builds the faster binary.
- jason_slack 10y agoHonest question: on OS X, Apple has embraced clang and not gcc anymore. When I use linux clang is also available. Can anyone chime in about how a developer would choose gcc over clang (and vice versa). I have to admit that even though I write in c++, I seldom pay attention to which compiler I would use for x vs y feature, etc. Compilers feel like a black-box to me. I don't go inside it. Edit: I don't know about Windows, I know gcc is available. I haven't looked if clang is. Edit 2: Intel also makes compilers, to which I own, but never use. I guess I feel like I am not doing anything specific to Intel
- jcranmer 10y agogcc generally provides somewhat better code than clang, both in runtime and in object size. Clang has traditionally done better at warnings and diagnostics, although gcc has definitely closed that space in the past few years (since 4.9 or so).
- jason_slack 10y agoare there circumstances where a developer should compile their products with more than one compiler to flush out issues, potentially fine tune/optimize code, etc? I've never thought about doing this.
- lallysingh 10y agoYes, at least make sure that your code compiles and the tests pass on more than one. That way you're sure that you're not depending on peculiars of one compiler (their specific behaviors that are undefined in the standard, optimizer actions, etc).
- bschwindHN 10y agoAnd a nice way to run multiple compilers easily is by using a tool like Travis CI with their compiler matrix support. https://docs.travis-ci.com/user/languages/c https://docs.travis-ci.com/user/languages/c
- beeforpork 10y agoAnd again, my favorite accidental usages of undefined behaviour in C++ are optimised into BS. (1) if (this == NULL): this is super useful in non-virtual functions, because NULL is the object that subclasses all classes, so the only universal error object. (2) memset in operator new: in C++03, we did not have initialisers inside struct{}, so quicky zero the obj to avoid error-prone manual inits of all embedded ints. This is really becoming ridiculous. Having a notion of how C/C++ corresponds to what the machine will do seems to be more and more regarded as evil.
- deleted 10y ago[deleted]
- Matheus28 10y agoExcept `if(this == nullptr)` doesn't always work: https://blogs.msdn.microsoft.com/oldnewthing/20160224-00/?p=93081 https://blogs.msdn.microsoft.com/oldnewthing/20160224-00/?p=... You might get a pointer to NULL+8 or something like that if the class inherents from more than one class. Maybe you should just write compliant code after all.