Why do projects use the -I include switch given the dangers?

What legitimate reasons are there for -I over -iquote? -I is standardized (at least by POSIX) while -iquote isn’t. (Practically, I’m using -I because tinycc (one of the compilers I want my project to compile with) doesn’t support -iquote.) How do projects manage with -I given the dangers? You’d have the includes wrapped in a … Read more

Is “sizeof new int;” undefined behavior?

The warning doesn’t state that it’s UB; it merely says that the context of use, namely sizeof, won’t trigger the side effects (which in case of new is allocating memory). [expr.sizeof] The sizeof operator yields the number of bytes occupied by a non-potentially-overlapping object of the type of its operand. The operand is either an … Read more

How to deal with global-constructor warning in clang?

Here is a simpler case that triggers the same warning: class A { public: // … A(); }; A my_A; // triggers said warning test.cpp:7:3: warning: declaration requires a global constructor [-Wglobal-constructors] A my_A; // triggers said warning ^~~~ 1 warning generated. This is perfectly legal and safe C++. However for every non-trivial global constructor … Read more

Is this change in overload resolution between Clang 3.5 and 3.6 correct or a bug?

I believe Clang is correct to produce this error: The [temp.inst] section of the C++ standard in paragraph 10 says: If a function template or a member function template specialization is used in a way that involves overload resolution, a declaration of the specialization is implicitly instantiated (14.8.3). Forming the implicit conversion sequence necessary to … Read more

GCC and Clang template call resolution differences

According to overload resolution, there are two viable functions: The specialization of the global operator|-template with deduced arguments and the specialization of the member operator function template. Both have the same signature – the member function template has an implicit object parameter of type Alice const& (see ยง13.3.1/4). So both viable functions (after template argument … Read more

clang_complete: where is the libclang.{so,dylib} in OS X?

With the latest (appstore) XCode 4.3.2, the location changed, it can now be found in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib The /Developer directory, among others, no longer exists by default. Everything is now packaged inside the XCode application, so that delta updates from the appstore work.