Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinGW Bug #3

Closed
h0tc0d3 opened this issue Aug 4, 2018 · 5 comments
Closed

MinGW Bug #3

h0tc0d3 opened this issue Aug 4, 2018 · 5 comments

Comments

@h0tc0d3
Copy link

h0tc0d3 commented Aug 4, 2018

Hi. In MinGW i have errors. Don't know how it fix. Maybe you have some ideas?
Thank you!

In file included from C:\Code\nvwa/debug_new.h:42,
                 from C:\Code\DllMain.cpp:4:
C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/ext/new_allocator.h: In member function '_Tp* __gnu_cxx::new_allocator<_Tp>::allocate(__gnu_cxx::new_allocator<_Tp>::size_type, const void*)':
C:\Code\nvwa/_nvwa.h:57:14: error: expected operator before 'nvwa'
 #define NVWA nvwa
              ^~~~
In file included from C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/i686-w64-mingw32/bits/c++allocator.h:33,
                 from C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/bits/allocator.h:46,
                 from C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/string:41,
                 from C:\Code\MMM.h:3,
                 from C:\Code\DllMain.cpp:6:
C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/ext/new_allocator.h:111:37: error: expected ')' before 'nvwa'
  return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
                                     ^
                                     )
C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/ext/new_allocator.h:111:37: error: expected ';' before 'nvwa'
  return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
                                     ^
                                     ;
C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/ext/new_allocator.h:111:60: error: expected type-specifier before ')' token
  return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
                                                            ^
In file included from C:\Code\nvwa/debug_new.h:42,
                 from C:\Code\DllMain.cpp:4:
C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/bits/stl_tempbuf.h: In function 'std::pair<_Tp*, int> std::get_temporary_buffer(std::ptrdiff_t)':
C:\Code\nvwa/_nvwa.h:57:14: error: expected operator before 'nvwa'
 #define NVWA nvwa
              ^~~~
In file included from C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/memory:66,
                 from C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/thread:39,
                 from C:\Code\MMM.h:4,
                 from C:\Code\DllMain.cpp:6:
C:/mingw/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/bits/stl_tempbuf.h:94:45: error: expected ')' before 'nvwa'
    _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp),
                                             ^
                                             )
#ifdef _DEBUG
   #include "nvwa/debug_new.h"
#endif

// On Init
#ifdef _DEBUG
	fopen_s(&nvwa::new_output_fp, "c:\\tools\\leak.txt" , "w");
	nvwa::new_autocheck_flag = false;
	nvwa::new_verbose_flag = true;
#endif

// On destroy
#ifdef _DEBUG
	nvwa::check_leaks();
#endif
@adah1972
Copy link
Owner

adah1972 commented Aug 5, 2018

You did include a complete test case, so I have to guess a bit. Did you put the inclusion of "nvwa/debug_new.h" after all other includes, esp. the system include files?

@h0tc0d3
Copy link
Author

h0tc0d3 commented Aug 5, 2018

mvwa.zip
Attached simple cmake project. Bug was in this toolchain https://sourceforge.net/projects/mingw-w64/

@adah1972
Copy link
Owner

adah1972 commented Aug 6, 2018

Just as I guessed, the code includes string.h and other stuff after including debug_new.h. Errors would occur any time the included file invokes operator new (as versus a simple new operator). Include debug_new.h last.

@h0tc0d3
Copy link
Author

h0tc0d3 commented Aug 6, 2018

Yep. QuikLua.h load string.h thread.h mutex, I can not remove them. Maybe have it any decision?

Leak found, works in MSVC. Mingw throw error.

#include <Windows.h>
#include "Lua.h"
#ifdef _DEBUG
	#include "nvwa/debug_new.h"
#endif
#include "QuikLua.h"
#include "Helper.h"

Work in both compilators, but leak have not found.

#include <Windows.h>
#include "Lua.h"
#include "QuikLua.h"
#include "Helper.h"
#ifdef _DEBUG
	#include "nvwa/debug_new.h"
#endif

@adah1972
Copy link
Owner

adah1972 commented Aug 6, 2018

Leaks should always be found, regardless of whether debug_new.h is included or not. The difference is whether the file/line information can be reported or not.

@h0tc0d3 h0tc0d3 closed this as completed Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants