7 ms·
GCC 5.1 released
- halosghost 12y agoSome of these are terrific changes! E.g., OpenMP 4.0 and Cilk Plus support, wew! I also love that ``gcc`` now defaults to ``-std=gnu11`` instead of ``-std=gnu89``; what a huge step forward! But, there were a couple of things in here that I was hoping to see but did not find (namely, it seems gcc still does not have ``-Weverything``). While I am glad to see gcc making progress, I feel bound to clang until gcc's warning/error reporting can get up-to-speed.
- reidrac 12y agoApparently -Wall and -Wextra is believed to be enough; not sure what to expect with -Weverything but I'm intrigued :) EDIT: interesting indeed. Thanks for the pointer! (Add warning levels) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53313 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53313
- mkaufmann 12y agoI like to use -Wpedantic for my own projects to keep the code clean and it helped my well. Its not included in -Wall and -Wextra.
- halosghost 12y agoYeah, as has been mentioned many times before `-Wall -Wextra` leaves out a ton of warnings/errors (despite what the names imply). `-Weverything` is an alias for enabling all warnings. I find it much better practice to enable all warnings and then selectively disable the ones which warn me about things I have done intentionally through pragmas in the code.
- thoughtpolice 12y agoGCC 5.1 defaults to having color diagnostics set to `auto`, meaning it will display nice, beautiful diagnostics like Clang does on your terminal, if that's what you're referring to. (You can also get these with GCC 4.9, too, using the `GCC_COLORS` environment variable). Personally I don't care about that as much as the optimization improvements this time arond, it seems. Better devirtualization? AutoFDO? Reuse of the PIC hard register, especially? (That will be a great win on 32 bit machines, and makes it all the more possible to enable things like PIE for 32-bit applications, where it would otherwise be a big penalty, as well as many other things.)
- halosghost 12y agoHaha, I wasn't actually referring to colored warning/error output (though it is a nice plus!). I was mostly referring to `clang`'s `-Weverything` and the absence of any such alias for `gcc`.
- thoughtpolice 12y agoGCC 5.1 defaults to having color diagnostics set to `auto`, meaning it will display nice, beautiful diagnostics like Clang does on your terminal, if that's what you're referring to.
- BinaryIdiot 12y ago> namely, it seems gcc still does not have ``-Weverything`` I would love to have a -Weverything; as a fairly rusty C++ dev I originally thought -Wall was supposed to have, you know, all but was pretty surprised to learn it didn't actually contain all. It would be great if they deprecated -Wall and made it so -Weverything always did all warnings (including any newly introduced warnings).
- jeorgun 12y agoClang's -Weverything isn't really as useful as it sounds; since it includes fairly-to-completely useless warnings like -Wc++98-compat, -Wpadded, or -Wweak-vtables, you'll end up spending so much time playing warning whack-a-mole that you might as well have not enabled the thing in the first place. At least that's been my experience.
- halosghost 12y agoI completely disagree. It's true that some of the warnings it enables aren't terribly useful, but being able to enable all warnings is very helpful instead of having to manually list ~40 flags. Additionally, -Wpadded and the like are actually helpful for optimizations. Plus, writing code (in C, I cannot speak for Cxx) which results in no warning output from `-Weverything` is actually not that difficult to do, and generally the result is that you've written more robust code in the process. A lot of projects are now trying to move to compile with `-Weverything` and not disable any warnings, and I personally think it's a great move.
- jeorgun 12y agoFor C, I'd agree that it's useful. The flags I listed have issues specifically for C++. -Wc++98-compat, on a C++11 or C++14 project, is about as helpful as you'd expect. -Wpadded is triggered pretty reliably by subclassess. And so forth. Of course it is possible to specifically disable useless warnings, but in my experience it's just as easy to add a reasonable selection of flags (say, -Wall -Wextra -Wold-style-cast -Wconversion -Wsign-conversion) than to start with -Weverything and work backwards. Still, it has been some time since I've tried using it; maybe I ought to give it another chance.
- nn3 12y agogcc $(gcc -v --help 2>&1 | awk '/-W/ && !/=/ && !/[oO]ptions/ && !/larger-than/ { print $1 }') Not particularly useful though.
- przemoc 12y agoJakub Jelinek's announcement on ML: https://gcc.gnu.org/ml/gcc/2015-04/msg00287.html https://gcc.gnu.org/ml/gcc/2015-04/msg00287.html And the same one for gmane lovers (like me): http://thread.gmane.org/gmane.comp.gcc.devel/139625 http://thread.gmane.org/gmane.comp.gcc.devel/139625
- ploxiln 12y agoI won't be able to use them in portable code anytime soon, but the new feature here that most interests me is __builtin_add_overflow, __builtin_sub_overflow and __builtin_mul_overflow "These builtins have two integral arguments (which don't need to have the same type), the arguments are extended to infinite precision signed type, +, - or * is performed on those, and the result is stored in an integer variable pointed to by the last argument. If the stored value is equal to the infinite precision result, the built-in functions return false, otherwise true. The type of the integer variable that will hold the result can be different from the types of the first two arguments." Handling all possible integer overflow with plain C is annoyingly tricky and for some critical paths in-efficient. These built-ins can often do a conditional jump based on the overflow bit in the flags register.
- mikeash 12y agoSounds useful for wrappers, where you could conditionally compile to use either these builtins, or the annoying, potentially slow, portable versions.
- cremno 12y agoSadly clang (the origin of those built-in functions) doesn't implement the type-generic ones and GCC doesn't implement __has_builtin yet.
- Someone 12y agoThat may be sooner than you think, depending on what you mean by portable. I think these functions originated as non-generic versions in clang (http://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions http://clang.llvm.org/docs/LanguageExtensions.html#builtin-f...). gcc copied them and now added generic variants. I think it is likely that clang will now copy gcc and add the generic variants. Edit: here is the request for gcc to copy clang: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59708 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59708 (nice discussion about the need to have builtins for overflow detection) And here is a request for clang to copy gcc's generic versions: https://llvm.org/bugs/show_bug.cgi?id=21716 https://llvm.org/bugs/show_bug.cgi?id=21716
- tuan5 12y agoI saw both C and Golang are promoted by 5.1.
- ehmmm 12y agoIt is so close to full C11 support. I think just threads.h are missing now.
- bstamour 12y agoI haven't really heard much buzz about C11 since its release. I don't mean to sound snarky (I'm really curious): does anyone really use C11 at all?
- huu 12y agoI use C++11 and it's awesome. It's expressive like python but still maintains strict type safety. I built a (still young) curl wrapper using C++11: https://github.com/whoshuu/cpr https://github.com/whoshuu/cpr Edit: Misread the parent posts and thought they were referring to C++11. Today I learned C11 is a separate standard.
- danners 12y agoIsn't that C++11?
- FnuGk 12y agothat looks like a c++ project that uses c++11 not c11
- Devid2014 12y agoNice looking project but unfortunately it is GPL. Unlike Curl it self because it uses MIT like license.
- huu 12y agoExcellent point, I just changed the license to MIT to be consistent with curl. Thanks for catching that.
- loup-vaillant 12y agoToo bad proprietary projects can't link against it. A loss for us all. Seriously? GPL stuff can be used with any internal stuff, and almost any Free stuff. Isn't that enough? Where is the loss exactly? Edit: okay, that wasn't the author's intention, and the consistency argument is a good one (least astonishment and all that). Still, the general argument holds.
- wnissen 12y agoWhoa, this is the first time the ABI has been deliberately broken since, what, 3.4? I see it's due to the small string optimization and a std::list that tracks its size, which will be nice but I don't know it's worth breaking compatibility for that by default. Still, it's an impressive string of compatibility, and I applaud the maintainers. I've successfully built 4.9.0 against 4.1.2 with exceptions, etc. and it Just Works.
- the_why_of_y 12y agoThe changes were necessary so that libstdc++ conforms to the C++11 standard, which introduced new requirements on std::list and std::string. And this time they managed to do it without a SONAME bump, which is nice.
- jcoffland 12y agoIt seems like the GCC guys have really kicked it up a notch. I think LLVM has inspired them to move it or loose it. At this rate they can expect to still be a relevent compiler system for a very long time.
- stefantalpalaru 12y agoAny news about escape analysis for gccgo?
- JoeAltmaier 12y agoI'm troubled that 'write-only variables are ... optimized out'. That means, no more embedded trace buffers in memory dumps? I've used that for decades to debug intermittent problems. Maybe there's some way to tag necessary write-only variables...
- JoachimSchipper 12y agovolatile works, asm works, and it's usually not hard to trick the optimizer.
- TheLoneWolfling 12y agoIt's becoming harder to trick the optimizer all the time. I mean, the goal of an optimizer is literally not to be able to be tricked into doing work it doesn't have to.
- JoachimSchipper 12y agoYes; e.g. http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/explicit_bzero.c http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string... demonstrates that rather well. Still, it is and will remain possible - and for the intended use, that's probably good enough. (It's not write - and - forget code where tricking the optimizer is security-critical.)
- TheLoneWolfling 12y agoIf you're having to trick the optimizer, you're doing something wrong. If the language is such that there are things in the language that inherently require tricking the optimizer, the language is doing it wrong.
- JoeAltmaier 12y agoI wondered about 'volatile'. Its not really meant for that - but maybe its enough to trigger 'hands off'.
- mattgodbolt 12y agoTook a little longer than I'd hoped but GCC explorer now has support for GCC 5.1 : https://gcc.godbolt.org https://gcc.godbolt.org It doesn't support LTO as yet due to the way it works so some of the juicier optimisations aren't visible. But you still get a chance to play about with the quality of the code generator.