Compiler error including windows.h

I build clang from the latest source using mingw-64/gcc-7.1. Using mingw-64/gcc-7.1 as the backend, when I compile:

// test_compiler.cpp

#include <windows.h>
int main()
{
return 0;
}

with the command line:

some_path/clang++" -c -x c++ -O0 -g -fno-inline -Wall -g -march=i686 -m32" -o "some_path\test_compiler.obj" "test_compiler.cpp"

I get:

In file included from test_compiler.cpp:1:
In file included from C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\windows.h:69:
In file included from C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\windef.h:8:
In file included from C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\minwindef.h:163:
C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\winnt.h:4720:18: error: default initialization of an object of const type 'const GUID' (aka 'const _GUID') without a user-provided default constructor
     DEFINE_GUID (GUID_MAX_POWER_SAVINGS, 0xa1841308, 0x3541, 0x4fab, 0xbc, 0x81, 0xf7, 0x15, 0x56, 0xf2, 0x0b, 0x4a);
                  ^
C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\winnt.h:4721:18: error: default initialization of an object of const type 'const GUID' (aka 'const _GUID') without a user-provided default constructor
     DEFINE_GUID (GUID_MIN_POWER_SAVINGS, 0x8c5e7fda, 0xe8bf, 0x4a96, 0x9a, 0x85, 0xa6, 0xe2, 0x3a, 0x8c, 0x63, 0x5c);
                  ^

etc. with the same errors for all the other DEFINE_GUID s in winnt.h

Needless to say compiling the same source with mingw-64/gcc-7.1 directly succeeds.

Is this a bug in the latest clang source ?

It’s a bug in the mingw headers. If you pass -fms-extensions -fms-extensions, clang will accept that code since Microsoft’s headers have the same bug.

Is it? Despite lack of a constructor the structure `GUID` is an aggregate, so aggregate initialization takes place. We do use the aggregate initialization syntax in our headers which is the same in C, C++98 and C++11, so there is no need to define a constructor explicitly.

It's a bug in the mingw headers. If you pass -fms-extensions -fms-extensions, clang will accept that code since Microsoft's headers have the same bug.

BTW using the clang-4.0 distribution with '-target i686-pc-windows-gnu' as a compiler and linker option, everything works correctly.

It's a bug in the mingw headers. If you pass -fms-extensions -fms-extensions, clang will accept that code since Microsoft's headers have the same bug.

I need to pass -fms-extensions twice ? I tried passing -fms-extensions once and the same error occurs. Needless to say when using mingw-64/gcc-7.1 -fms-extensions is not being passed and it is working correctly.