From 65c634ed80b1575174c868f94e0fa5d2c8cb5ee0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Feb 2016 23:39:44 +0100 Subject: [PATCH] Don't define interfaces inside anonymous namespace in wxMSW IAutoCompleteDropDown interface was defined inside anonymous namespace to avoid clashing with the same interface possibly (but not necessarily) declared in the standard headers. However gcc 4.9 is smart enough to realize that no classes deriving from a class in an anonymous namespace can exist and so it devirtualizes the calls to virtual methods of the objects of this type when compiling with optimizations enabled. And it does it even if it means replacing the call to a virtual method with just a call to __cxa_pure_virtual(), i.e. crashing during run-time. Prevent it from doing this by moving class declarations outside of the anonymous namespace and fix the crash when using wxTextEntry::AutoComplete() in the code compiled with g++ 4.9. (this is a backport of 4475fe36a54cd62457dcd73c8739b1e7d46e1cde from master) --- src/msw/textentry.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/msw/textentry.cpp b/src/msw/textentry.cpp index e0467ec219..2d19794ae0 100644 --- a/src/msw/textentry.cpp +++ b/src/msw/textentry.cpp @@ -81,9 +81,6 @@ // above. #include -namespace -{ - // Normally this interface and its IID are defined in shobjidl.h header file // included in the platform SDK but MinGW and Cygwin don't have it so redefine // the interface ourselves and, as long as we do it all, do it for all @@ -96,6 +93,9 @@ public: virtual HRESULT wxSTDCALL ResetEnumerator() = 0; }; +namespace +{ + DEFINE_GUID(wxIID_IAutoCompleteDropDown, 0x3cd141f4, 0x3c6a, 0x11d2, 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb);