clang++

How to pass C++11 flag down to “npm install”?

女生的网名这么多〃 提交于 2021-02-11 13:32:55
问题 I am trying to install the "opencv4nodejs" package on a MAC by running this command: CXXFLAGS=-std=gnu++11 npm i -g opencv4nodejs That gives me the following error: /usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/opencv/modules/highgui/src/window_cocoa.mm:269:25: error: non-constant-expression cannot be narrowed from type 'int' to 'CGFloat' (aka 'double') in initializer list [-Wc++11-narrowing] NSSize size = { width, height }; ^~~~~ /usr/local/lib/node_modules

Analyzing a simple C++ program with Frama-C

一笑奈何 提交于 2021-02-10 20:15:37
问题 I started learning C++ from a great tutorial available at https://learnxinyminutes.com/docs/c++/ and would like to analyze in Frama-C a simplest example that shows references: using namespace std; #include <iostream> #include <string> int main() { string foo = "I am foo"; string bar = "I am bar"; string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference cout << fooRef; // Prints "I am foo. Hi!" // Doesn't reassign "fooRef". This is the

Analyzing a simple C++ program with Frama-C

这一生的挚爱 提交于 2021-02-10 20:11:08
问题 I started learning C++ from a great tutorial available at https://learnxinyminutes.com/docs/c++/ and would like to analyze in Frama-C a simplest example that shows references: using namespace std; #include <iostream> #include <string> int main() { string foo = "I am foo"; string bar = "I am bar"; string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference cout << fooRef; // Prints "I am foo. Hi!" // Doesn't reassign "fooRef". This is the

Code using SFINAE working with GCC but not with Clang

拈花ヽ惹草 提交于 2021-02-10 05:12:52
问题 I'm trying to use SFINAE in C++11 to implement a serialization library. My code works fine with GCC but not with Clang. I've reduced it here to a minimal code: template <typename A, typename T> constexpr auto has_save_method(A& ar, T& t) -> decltype(t.save(ar), bool()) { return true; } template<class A, typename T, bool has_save> struct saver; template<class A, typename T> struct saver<A,T,true> { static void apply(A& ar, T& t) { t.save(ar); } }; class MyClass { public: template<typename A>

Thread sanitizer reports data race when using std::packaged_task/std::exception_ptr

心不动则不痛 提交于 2021-02-09 11:00:45
问题 I am experiencing some issues with thread sanitizer (TSan) complaining about a data race in some production code where std::packaged_task are handed over to a dispatcher thread by wrapping them in a std::function. For this question I have simplified what it does in production, while triggering TSan. The implementation is similar to the answer given by Anthony Williams in this question (at least that is my understanding): Non-obvious lifetime issue with std::promise and std::future. Note that

Thread sanitizer reports data race when using std::packaged_task/std::exception_ptr

☆樱花仙子☆ 提交于 2021-02-09 11:00:27
问题 I am experiencing some issues with thread sanitizer (TSan) complaining about a data race in some production code where std::packaged_task are handed over to a dispatcher thread by wrapping them in a std::function. For this question I have simplified what it does in production, while triggering TSan. The implementation is similar to the answer given by Anthony Williams in this question (at least that is my understanding): Non-obvious lifetime issue with std::promise and std::future. Note that

Error: use of overloaded operator '[]' is ambiguous while building for i386

送分小仙女□ 提交于 2021-02-09 08:34:02
问题 Consider the following code: #include <stdio.h> #include <stdint.h> class test_class { public: test_class() {} ~test_class() {} const int32_t operator[](uint32_t index) const { return (int32_t)index; } operator const char *() const { return "Hello World"; } }; int main(void) { test_class tmp; printf("%d\n", tmp[3]); return 0; } When I use command clang++ -arch i386 test.cc to build those codes, it yields the following on clang++ (Apple LLVM version 9.1.0 (clang-902.0.39.1)): test.cc:24:21:

Error: use of overloaded operator '[]' is ambiguous while building for i386

a 夏天 提交于 2021-02-09 08:29:32
问题 Consider the following code: #include <stdio.h> #include <stdint.h> class test_class { public: test_class() {} ~test_class() {} const int32_t operator[](uint32_t index) const { return (int32_t)index; } operator const char *() const { return "Hello World"; } }; int main(void) { test_class tmp; printf("%d\n", tmp[3]); return 0; } When I use command clang++ -arch i386 test.cc to build those codes, it yields the following on clang++ (Apple LLVM version 9.1.0 (clang-902.0.39.1)): test.cc:24:21:

Do compilers optimize switches differently than long if-then-else chains?

橙三吉。 提交于 2021-02-07 14:53:04
问题 Suppose I have N different integral values known at compile time, V_1 through V_N. Consider the following structures: const int x = foo(); switch(x) { case V_1: { /* commands for V_1 which don't change x */ } break; case V_2: { /* commands for V_1 which don't change x */ } break; /* ... */ case V_N: { /* commands for V_1 which don't change x */ } break; } versus const int x = foo(); if (x == V_1) { /* commands for V_1 which don't change x */ } else if (x == V_2) { /* commands for V_2 which

Clang 3.7.0 complains of class not being literal because it is not an aggregate and has no constexpr constructors

孤街醉人 提交于 2021-02-05 07:23:20
问题 The following code compiles fine in GCC (4.9.3) and VC++ (19.00.23506) but gives these error in Clang (3.7.0). error: constexpr function's return type 'Foo' is not a literal type note: 'Foo' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors Code: #include <iostream> #include <vector> struct Foo { std::vector<int> m_vec; Foo(const int *foo, std::size_t size=0):m_vec(foo, foo+size) {;} //Foo(const std::initializer_list<int>