News for hackers. Stuff that matters.
Re:Clang is now feature complete for C++14 by arcatek on Thursday November 07, 2013 @05:18AM (#6688643)
We shouldn't worry about C++11 / C++14 compiler support, which will eventually come, but rather standard libraries. It's a pain that libstdc++ still does not support some C++11 features[1] (no std::move on streams, for example).

They probably have good reasons, such as keeping the same ABI as long as possible, but it's sometimes very frustrating.

[1] http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#s...

Re:Clang is now feature complete for C++14 by fhd2 on Thursday November 07, 2013 @05:23AM (#6688658)
Good point, I believe clang + libstdc++ is a much more common combination than clang + libc++.

One thing I really don't like about libc++ is that it doesn't support anything from TR1 - makes it needlessly difficult to use in existing code bases.

Re:Clang is now feature complete for C++14 by bloodorange on Thursday November 07, 2013 @11:03AM (#6690088)
The only sore thumb in libstdc++ is the regex library. It doesn't work and the headers exist. There are no warnings while compiling the code too. So, it'll appear like everything is dandy and it blows up at run time and usually developers don't think the fault lies in the library code...

This has led to a few hours down the drain...

Re:Clang is now feature complete for C++14 by agwa on Thursday November 07, 2013 @01:35PM (#6691333)
I share your pain. Fortunately, gcc 4.9 will have <regex> support: http://gcc.gnu.org/gcc-4.9/changes.html
Re:Clang is now feature complete for C++14 by eonil on Thursday November 07, 2013 @07:44AM (#6689005)
I don't agree.
Re:Clang is now feature complete for C++14 by pmelendez on Thursday November 07, 2013 @10:54AM (#6690029)
Would you mind to say why?
Re:Clang is now feature complete for C++14 by eonil on Thursday November 07, 2013 @04:33PM (#6692556)
What I don't agree was this phrase.

    *much more common combination*
Why? no clue, no reason. But Clang with libc++? There're reasons.

The primary Clang user groups are Apple and FreeBSD communities. a.k.a. anti-GCC groups. Both of them really want to avoid any GCC stuff and are officially deprecating all the GCC stuff. Having dependency to GCC stuff is nonsense on these platforms. If common developers are sane enough, they' won't use libstdc++.

And other group is the Linux development. But I don't think there're really many developers who are using Clang for production on Linux. There's no big push from the platform, and also no big benefits. But there're many shortcomings for using Clang. It's not installed by default, not supported by platform, not tested much.

If there're some people want to adapt Clang on Linux even now, they won't hesitate to use libc++. And the others will just stays in good old GCC with libstdc++.

Re:Clang is now feature complete for C++14 by pmelendez on Thursday November 07, 2013 @04:54PM (#6692688)
>"and also no big benefits"

I think there are several benefits in using clang tools. You might find useful the Chandler Carruth's talk on Going Native on which he demoed some great tools that doesn't really have alternative on the gnu toolchain.

http://channel9.msdn.com/Events/GoingNative/2013/The-Care-an...

Re:Clang is now feature complete for C++14 by snogglethorpe on Thursday November 07, 2013 @09:32PM (#6694069)
Clang certainly has its advantages (the faster compile times are very nice), but for a typical user that just wants to compile stuff, there's really nothing huge—and as always they need to balanced against the disadvantages. In general it's often a wash, and you may as well just use whatever comes with your system or whatever your friends use...

For me, the killer is typically optimization: e.g. for a CPU-intensive app I work on, gcc generates a binary that is twice as fast as what clang generates (this has been true for ages and across many compiler versions). I can live with slightly pokey compiles, but having my program take one week to execute instead of two is pretty compelling...

Re:Clang is now feature complete for C++14 by profquail on Friday November 08, 2013 @08:47AM (#6695940)
Would you mind submitting a bug report (with a reproduction case, if you're able) to the Clang team or mailing list? IIRC, they have an automated test suite for performance and regression testing; I'm sure they would greatly appreciate you taking the time to submit a test case where clang is producing egregiously slow binaries.
Re:Clang is now feature complete for C++14 by snogglethorpe on Friday November 08, 2013 @06:40PM (#6699855)
I could try, but although the difference seems localized to a fairly small number of functions, I haven't been able to precisely identify why it's so slow (there's no single inner loop etc that's slow), and shrinking it to something minimal would be hard...
Re:Clang is now feature complete for C++14 by thwest on Friday November 08, 2013 @12:15AM (#6694585)
Many people prefer the error messages from clang
Re:Clang is now feature complete for C++14 by GalacticDomin8r on Friday November 08, 2013 @10:19PM (#6700541)
> The primary Clang user groups are Apple and FreeBSD communities. a.k.a. anti-GCC groups.

I think you meant to say anti-GPLv3 groups and you also forgot to include Linux kernel devs.

Re:Clang is now feature complete for C++14 by cokernel_hacker on Thursday November 07, 2013 @05:20AM (#6688653)
libcxx has not only implemented C++14 but they have also implemented all known defect reports at roughly the rate they get published!

http://libcxx.llvm.org/cxx1y_status.html

Re:Clang is now feature complete for C++14 by mekishizufu on Thursday November 07, 2013 @05:32AM (#6688684)
Unfortunately libc++ is fully supported on Mac OSX only, with ports on their way. I actually use libc++ on linux but there're still some things that need to be fixed. [1]

[1] http://libcxx.llvm.org/results.Linux.html

Re:Clang is now feature complete for C++14 by cokernel_hacker on Thursday November 07, 2013 @05:39AM (#6688699)
Those results are from over a year ago [1].

[1] http://llvm.org/viewvc/llvm-project?view=revision&revision=1...

Re:Clang is now feature complete for C++14 by mekishizufu on Thursday November 07, 2013 @06:01AM (#6688745)
Good point. I will run the tests myself to see the current status.
Re:Clang is now feature complete for C++14 by eonil on Friday November 08, 2013 @05:07AM (#6695406)
I still see the cuchar fail on Clang source 3.3, but maybe different on trunk.
Re:Clang is now feature complete for C++14 by X-Istence on Thursday November 07, 2013 @01:10PM (#6691121)
Not just Mac OS X, it is in the FreeBSD base system by default, it is the replacement for the libstdc++. See FreeBSD 10 where the switch was made :-).
Re:Clang is now feature complete for C++14 by eonil on Thursday November 07, 2013 @07:47AM (#6689012)
Doesn't it run on FreeBSD?
Re:Clang is now feature complete for C++14 by 0x09 on Thursday November 07, 2013 @07:56AM (#6689040)
David Chisnall likes to point out that it actually passes more of its test suite on FreeBSD than on OS X.

edit: thanks misframer

Re:Clang is now feature complete for C++14 by misframer on Thursday November 07, 2013 @08:22AM (#6689128)
Chisnall
Re:Clang is now feature complete for C++14 by eliben on Thursday November 07, 2013 @08:04AM (#6689063)
That's not entirely true. libc++ works on Linux too. In fact, Google's PNaCl has experimental libc++ support that's completely cross-platform.
Re:Clang is now feature complete for C++14 by pmelendez on Thursday November 07, 2013 @10:55AM (#6690034)
And in windows too http://llvm.org/builds/
Re:Clang is now feature complete for C++14 by fedvasu on Thursday November 07, 2013 @04:52PM (#6692670)
yeah right. It is beta-quality unfit for pre-packaging in distro's. ABI incompatible with libstdcxx and deliberately OS X only. (It works sure (i mean kinda) no one is actually a linux port developer or maintainer not yet)
Re:Clang is now feature complete for C++14 by MichaelMoser123 on Thursday November 07, 2013 @06:36AM (#6688821)
Oh! before doing C++14 gcc should please fix the std::list class; the size() method walks over the whole list in order to determine its size, outrageous.

template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class list : protected _List_base<_Tp, _Alloc> { ... size_type size() const { return std::distance(begin(), end()); }

Re:Clang is now feature complete for C++14 by octo_t on Thursday November 07, 2013 @08:14AM (#6689091)
std::list is a doubly linked list, how else do you propose they do this? This is traditionally how list sizes are calculated.

(libc++ keeps a track of the size somewhere, but this in occurs a 4/8 byte overhead)

Re:Clang is now feature complete for C++14 by cmircea on Thursday November 07, 2013 @08:30AM (#6689150)
I think everyone will agree that using 4 bytes to store the size a much better idea than potentially enumerating millions of nodes just to count them, in the process completely blowing the cache and any optimizations the processors may do.

It's four goddamn bytes. Or eight if you really want more than 4 billion elements.

Re:Clang is now feature complete for C++14 by berkut on Thursday November 07, 2013 @09:33AM (#6689482)
Most STL implementations have always done this. This is one reason why it's better to use the empty() check for an empty container instead of size() == 0 for all container types.

Also, linked lists are notoriously crap for cache coherency / processor pre-fetching and branch prediction by processors anyway, given that there's no guarantee where each node will be allocated - the only way to do that is pull them off a slab allocator or something, in which case you might as well use a vector or deque anyway...

Re:Clang is now feature complete for C++14 by cmircea on Thursday November 07, 2013 @03:50PM (#6692285)
Sure, but blowing the cache just to count is nuts.
Re:Clang is now feature complete for C++14 by apaprocki on Thursday November 07, 2013 @08:35AM (#6689175)
> It's four goddamn bytes. Or eight if you really want more than 4 billion elements.

As long as you don't have millions of lists with a few elements each -- you can't presume that they are only used one way :)

Re:Clang is now feature complete for C++14 by Someone on Thursday November 07, 2013 @09:39AM (#6689512)
According to http://www.cplusplus.com/reference/list/list/size/, list::size must be constant time in C++11.

That may make 'splice' slower. See http://home.roadrunner.com/~hinnant/On_list_size.html (I think that could be solved by having list iterators carry a field pointing to their container, but haven't given it much thought. Corrections welcome)

Re:Clang is now feature complete for C++14 by TwistedWave on Thursday November 07, 2013 @03:41PM (#6692234)
Having list iterators carry a field pointing to their container wouldn't help you determine the number of objects between two iterators when you splice, which is what you need in order to maintain the object count.

Storing an index in the iterator would not be a solution either. That would mean updating the index in all the existing iterators when you insert an object in the list.

Re:Clang is now feature complete for C++14 by Someone on Thursday November 07, 2013 @06:27PM (#6693272)
Of course. Thanks.
Re:Clang is now feature complete for C++14 by sharth on Thursday November 07, 2013 @10:27AM (#6689806)
It changes the ABI of std::list, which is a serious concern.
Re:Clang is now feature complete for C++14 by snogglethorpe on Thursday November 07, 2013 @09:36PM (#6694084)
... and figuring out how to deal with that is the reason that libstdc++ is moving slowly on this.

libc++ has the luxury of assuming c++11.

Re:Clang is now feature complete for C++14 by angersock on Thursday November 07, 2013 @09:34AM (#6689488)
No, really, it's quite a safe assumption.

Hell, you probably lose that much to padding somewhere anyways.

Re:Clang is now feature complete for C++14 by vinkelhake on Thursday November 07, 2013 @01:01PM (#6691039)
Then you might be better off with a std::forward_list which is typically the size of a pointer.
Re:Clang is now feature complete for C++14 by beerscout on Thursday November 07, 2013 @09:52AM (#6689597)
Not everybody will agree. One of the main advantages of std::list is splicing that can be done in O(1) if the size is not stored.
Re:Clang is now feature complete for C++14 by protomyth on Thursday November 07, 2013 @01:00PM (#6691033)
If the standard says it needs to be O(1) then you implement it that way and have a different list for fast splicing if needed.
Re:Clang is now feature complete for C++14 by astrodust on Thursday November 07, 2013 @11:09AM (#6690125)
Just make it the native size based on architecture. 4-byte int for 32-bit, 8-byte for 64-bit. It's impossible to store more than 4 billion elements on a 32-bit machine, you run out of memory first.
Re:Clang is now feature complete for C++14 by pmelendez on Thursday November 07, 2013 @09:32AM (#6689477)
The standard in C++11 demands that size must be O(1). Also, there are some compilers that already are complaint in that regard.
Re:Clang is now feature complete for C++14 by ajross on Thursday November 07, 2013 @01:08PM (#6691099)
That's new in C++11 though, isn't it? I'm pretty sure (i.e. I haven't checked the spec) that as far as C++03 the complexity was allowed to be linear. Honestly my sense of aesthetics agrees -- linked lists aren't supposed to have constant-time operations, there are better choices if that is a requirement. And if you want an augmented data structure you should cook your own: a list with extra tracking (i.e. ever node needs to have a pointer to the global thingy!) and insertion hooks isn't a "list" any more.
Re:Clang is now feature complete for C++14 by pmelendez on Thursday November 07, 2013 @03:09PM (#6692052)
Yeah, they changed the wording from "should" to "must" be O(1) in C++11, which means that before, even when they encourage the implementer to do it constant, that was in fact optional.

I don't that tracking the size would be a big deal, if you think that doing that they wouldn't be a linked list any more, you could think it as a linked link wrapper.

In any case the complexity guarantees of all the other operations remain true so I don't think it is a big deal.

Re:Clang is now feature complete for C++14 by ape4 on Thursday November 07, 2013 @01:34PM (#6691327)
Make your own wrapper.
Re:Clang is now feature complete for C++14 by MichaelMoser123 on Friday November 08, 2013 @05:13AM (#6695427)
That's why i like C; you never bitch about such things, you just do your own list;

In C++ you are supposed to reuse standard abstractions; So you can - do your own std::list; (still have to copy iterators and everything into it;-) - do your own wrapper around std::list that exposes a weaker interface, - make your own list and everybody start to bitch that you are reinventing the wheel.

Re:Clang is now feature complete for C++14 by ape4 on Friday November 08, 2013 @03:58PM (#6699111)
As you know in C++ you can do things the C++ way or the C way. That's why I like C++. If you want O(1) for size() of a collection you can use std::vector<> Of course, it doesn't suit every situation.
Re:Clang is now feature complete for C++14 by fafner on Thursday November 07, 2013 @06:47AM (#6688849)
Patches are welcome. But it requires fsf copyright assignment.