clang

Xcode 4.5 and OpenMP with Clang (Apple LLVM) uses only one core

风流意气都作罢 提交于 2019-12-22 05:48:13
问题 We are using Xcode 4.5 on a C++11 project where we use OpenMP to speed up our computation: #pragma omp parallel for for (uint x=1; x<grid.width()-1; ++x) { for (uint y=1; y<grid.height()-1; ++y) { // code } } Although the Activity Monitor shows multiple threads being used by the program we observed that only one core is used: We also run the same code on Ubuntu using GCC 4.7 and we observed contention on all cores. Could it be that the OpenMP support has been removed in the Apple LLVM? Is

error: jump to label 'foo' crosses initialization of 'bar'

久未见 提交于 2019-12-22 05:21:56
问题 The following C++ example fails to compile with gcc or clang, but only generates a warning with ICC, and nothing at all with MSVC: int main(int argc, char *argv[]) { if (argc < 2) goto clean_up; #if 1 // FAIL int i = 0; #elif 0 // workaround - OK { int i = 0; } #else // workaround - OK int i; i = 0; #endif clean_up: return 0; } g++: init.cpp:13: error: jump to label ‘clean_up’ init.cpp:4: error: from here init.cpp:7: error: crosses initialization of ‘int i’ clang++: init.cpp:4:9: error:

__STDC_LIB_EXT1__ availability in gcc and clang

僤鯓⒐⒋嵵緔 提交于 2019-12-22 05:10:55
问题 Since a quick Google search did not find anything, I will try to ask here (since many people involved in gcc/clang hang around here) - What is the status of __STDC_LIB_EXT1__ in gcc/clang? We are developing a cross platform applicataion and I wanted to use some of the safe bounds checking functions from <stdio.h> (which by miracle are available on Visual Studio 2017), but could not compile the code with Xcode 9.2. I assumed maybe the clang version Xcode uses is outdated, but gcc 6.3.0 on

Clang reject type_info as incomplete although <typeinfo> is included

这一生的挚爱 提交于 2019-12-22 05:09:38
问题 I'm lost as to why Clang rejects the following code: #include <typeinfo> #include <exception> const char* get_name( const std::exception_ptr eptr ) { return eptr.__cxa_exception_type()->name(); } int main() {} It OK with GCC, but Clang complains about type_info being an incomplete type: $ g++-4.7 -std=c++0x -O3 -Wall -Wextra t.cc -o t $ clang++-3.2 -std=c++0x -O3 -Wall -Wextra t.cc -o t t.cc:6:37: error: member access into incomplete type 'const class type_info' return eptr.__cxa_exception

Should non-capturing generic lambdas decay to function pointers?

江枫思渺然 提交于 2019-12-22 05:03:03
问题 Consider the following code: int main() { auto l = [](auto){}; void(*p)(int) = l; } It works just fine both with GCC and clang. Let's consider the following slightly modified version: int main() { auto l = [](auto...){}; void(*p)(int) = l; } In this case, clang still accepts it while GCC rejects it. Is there any reason for which this code should be rejected or is it a bug of the compiler? I'm going to open an issue, but I'd like to know if there exists any proposal that could have been

How to make gcc/clang warn about missing breaks in switch statements

拈花ヽ惹草 提交于 2019-12-22 04:49:09
问题 Is there any way to make gcc or clang warn about missing breaks in switch statements? Specifically, I almost always want case statements to end with breaks, and it would be great it I could get the compiler to complain if I don't. Even better would be if it would look for either a break statement or a "// fall through" comment. Is there a different solution people use to help themselves not screw this up? 回答1: With Clang trunk, use -Wimplicit-fallthrough . If you're using C++11, intentional

Why does this code give the error, “template specialization requires 'template<>'”?

人盡茶涼 提交于 2019-12-22 04:39:25
问题 When I try to compile this with Clang template<class T> struct Field { char const *name; Field(char const *name) : name(name) { } }; template<class Derived> class CRTP { static Field<Derived> const _field; }; class Class : public CRTP<Class> { }; Field<Class> const CRTP<Class>::_field("blah"); int main() { } I get error: template specialization requires 'template<>' Field<Class> const CRTP<Class>::_field("blah"); ~~~~~~~~~~~ ^ I don't understand the error at all. What is wrong with my

Is Clang really this smart?

天大地大妈咪最大 提交于 2019-12-22 04:24:07
问题 If I compile the following code with Clang 3.3 using -O3 -fno-vectorize I get the same assembly output even if I remove the commented line. The code type puns all possible 32-bit integers to floats and counts the ones in a [0, 1] range. Is Clang's optimizer actually smart enough to realize that 0xFFFFFFFF when punned to float is not in the range [0, 1], so ignore the second call to fn entirely? GCC produces different code when the second call is removed. #include <limits> #include <cstring>

clang vs gcc - empty generic lambda variadic argument pack

…衆ロ難τιáo~ 提交于 2019-12-22 04:24:06
问题 I think I found another "clang vs gcc" inconsistency between lambdas and callable objects. decltype(l)::operator() should be equivalent to C::operator() , but if variadic pack is left empty in the generic lambda, gcc refuses to compile: 15 : error: no match for call to '(main()::) (int)' l(1); 15 : note: candidate: decltype (((main()::)0u).main()::(x, )) (*)(auto:1&&, auto:2&&, ...) 15 : note: candidate expects 3 arguments, 2 provided 14 : note: candidate: template main():: auto l = [](auto&&

iOS: Block property directly set crashes when accessed

a 夏天 提交于 2019-12-22 04:16:23
问题 Consider the following code: @interface ClassA : NSObject @property (nonatomic, copy) void(^blockCopy)(); @end @implementation ClassA @synthesize blockCopy; - (void)giveBlock:(void(^)())inBlock { blockCopy = inBlock; } @end Then use it in a class which has a strong property of type ClassA called someA : self.someA = [[ClassA alloc] init]; [self.someA giveBlock:^{ NSLog(@"self = %@", self); }]; dispatch_async(dispatch_get_main_queue(), ^{ self.someA.blockCopy(); self.someA = nil; }); If I run