clang and gcc -O3 bug amongst other issues?

Hello Everyone

The following program exhibits a few interesting things to me regarding clang/gcc/libcxx and maybe also the C/C++ standard.
I would appreciate anyone’s comments on this, particularly those of Richard Smith who has a keen eye on much of this subject area.

  • If I, take this program:.

#include
using namespace std;
#include <windows.h>

int main()
{
}

Then if I compile it on a platform that has Windows.h using libcxx, e.g.
svn co http://llvm.org/svn/llvm-project/libcxx/trunk /libcxx
clang++ -nostdinc++ -I/libcxx/include -std=c++11 -O3 -c wc.cpp

Then I observe compiler errors with-O3 but with -O0 or no option it compiles without error. The same happens with g++.

The example code was actually distilled from compiling with the popular Ninja code base FWIW.

The errors are: