https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97362
Bug ID: 97362 Summary: __deref in <functional> in debug mode clashes with Windows SDK internal macro Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: frankhb1989 at gmail dot com Target Milestone: --- Case: #include <windows.h> #include <functional> int main() {} /tmp $ g++ -D_GLIBCXX_DEBUG a.cc In file included from F:/msys64/mingw64/include/c++/10.2.0/debug/debug.h:133, from F:/msys64/mingw64/include/c++/10.2.0/bits/stl_algobase.h:69, from F:/msys64/mingw64/include/c++/10.2.0/array:40, from F:/msys64/mingw64/include/c++/10.2.0/tuple:39, from F:/msys64/mingw64/include/c++/10.2.0/functional:54, from a.cc:2: F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:424:15: error: expected unqualified-id before ')' token 424 | __deref(); | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:427:34: error: expected primary-expression before '<' token 427 | typename = decltype(__deref<_It>() < __deref<_It>())> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:427:38: error: expected primary-expression before '>' token 427 | typename = decltype(__deref<_It>() < __deref<_It>())> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:427:40: error: expected primary-expression before ')' token 427 | typename = decltype(__deref<_It>() < __deref<_It>())> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:427:51: error: expected primary-expression before '<' token 427 | typename = decltype(__deref<_It>() < __deref<_It>())> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:427:55: error: expected primary-expression before '>' token 427 | typename = decltype(__deref<_It>() < __deref<_It>())> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:427:57: error: expected primary-expression before ')' token 427 | typename = decltype(__deref<_It>() < __deref<_It>())> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:441:42: error: expected primary-expression before '<' token 441 | = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:441:46: error: expected primary-expression before '>' token 441 | = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:441:48: error: expected primary-expression before ')' token 441 | = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:441:58: error: expected primary-expression before '<' token 441 | = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:441:62: error: expected primary-expression before '>' token 441 | = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))> | ^ F:/msys64/mingw64/include/c++/10.2.0/debug/functions.h:441:64: error: expected primary-expression before ')' token 441 | = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))> This is reproducible with MSYS2's {i686, x86_64}-w64-mingw32-g++. Note it compiles without -D_GLIBCXX_DEBUG. The offending `__deref` is from WinSDK header <sal.h> (also available in mingw-w64 for compatibility). As a system header, it is legitimate to have reserved identifiers. Although the workaround is simple (by #undef, since <specstrings_undef.h> is not available in mingw-w64 yet), it is still annoying and confusing. It seems a quick workaround by avoiding using `__deref` here is more appropriate.