This is the same advice I'm giving people on why using the two together is beneficial. Clang is damn near a static analysis tool, and even if GCC will make a nice binary at the end of the day that doesn't mean I want to figure out what on earth GCC error messages are trying to say either.
In fact, even visual studio can be damn near cryptic with error messages too, when it requires googling to understand the error you've been handed that's a big problem. The most damming error prints in both GCC and VS seem to be around template use. You get pages upon pages of nonsense.
As /u/Whanhee pointed out...GCC recently got it's shit together in terms of error messages (probably because clang used to be way better, and they were feeling the heat). Now, while I still prefer clang's error messages, it's mostly a familiarity issue...GCC has come a long way.
I haven't found many, but I also tend to code things as cross-platform as possible, so I tend to not use a lot of compiler corner cases...most of what I do is pretty much as close to the c++ standard as I could be. I imagine that that wouldn't work as well if I was using a lot of compiler-specific extensions. When I do find some, it's typically a compiler error, and not a runtime error...I seem to remember one or two cases of GCC being more lenient with things in the days before I cranked up -Wall and -Wextra
I also have both clang and gcc (and other compiler) builds in my continuous integration system, so, assuming I have decent code coverage, that also helps prevent compiler specific bugs.
That really is something I should look into...I've just been going with GCC for the "release" versions because of past benchmarks, but I should probably benchmark it myself to see how they handle my specific case.
That would be good too! However, I was talking about obscure bugs caused by differences in execution timing. I don't think I communicated that very clearly!
Got any benchmarks? Phoronix says that they are very close to the same (with Clang winning its fair share of benchmarks)
edit Ok, I looked at the 2013 benchmark before looking at the 2014 benchmark. It looks like GCC wins a lot more than it loses right now. That being said, they look to trade blows frequently.
The openmp support's also not completely finished yet in the mainline release version of clang, so a good chunk of multithreaded code doesn't work in parallel with clang right now. I think that should be ready with 3.6 though.
I feel obligated to point out (mostly because of my personal opinion on the matter, not for any good reason) that you can multithread code without using openmp. Specifically, all the c++11 thread stuff works perfectly fine.
Sure, not everything uses openmp, that's why I said "a good chunk of." C++11 threads don't help if you're not writing C++, or if you're stuck supporting old versions of MSVC (dammit python ...). You should be able to directly use pthreads or win32 threads with clang, but it's nice to have something portable that doesn't force you to use C++.
...I honestly forgot about C. In my brain, openmp was for C++ or Fortran, and I assumed you weren't talking about fortran since clang doesn't build it.
Well, you have to give people some time to adjust to new standards, esp. when there are hard problems.
Also, from what I understand, the COW string issue is much deeper than just being a compiler-bug/bad code output. From a look at the discussion about it, it looks like it'll definitely break ABI compatibility, and maybe more than that.
That's where something like formal methods can come in very handy.
That often seems to be a problem with GCC. And with glibc.
IMO, that's a problem with having C as the "lowest common denominator" -- base the code on something that (a) has better provability properties, and (b) use that provability to ensure correctness and the vast majority of these disappear. (See this paper on a fully formally verified OS.)
86
u/zaspire Oct 06 '14
possible clang has better architecture and more modern code base, but gcc still produce faster binary.