Re: [Mingw-w64-public] exceptions weirdness
2014-08-24 23:48 GMT+02:00 Yaron Keren yaron.ke...@gmail.com: Hi Tai, Thanks for looking into this. You are correct the right frontend should be used, however this isn't the root of the problem. It works since g++ defaults to -shared-libgcc while gcc defaults to -static-libgcc. If you force g++ to static link libgcc, the exception is still uncaught: g++ -static-libgcc a.cpp -lstdc++ a Yaron If you link to static libgcc, you should also link libstdc++ statically. It would make no sense to do otherwise. A shortcut for all this would be to use -static, but this will also force you to use static versions of all other libraries you link, which may or may not be what you want. Ruben 2014-08-25 0:18 GMT+03:00 Kai Tietz ktiet...@googlemail.com: Hi Yaron, I can't reproduce your reported issue by using proper frontends. You shouldn't use gcc frontend. Instead use g++. Later automatically adds proper link-libraries for c++ automatically. So you don't need to add -lstdc++ manual. By using 'g++ -o a a.cpp ./a' it works for me as expected. Kai -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] exceptions weirdness
Hi Ruben, Thanks for pointing this out, the problem is indeed that libstdc++ is linked to the dynamic ligcc while the program (as above) links to the static version of libgcc. There are two seperate copies of libgcc that do not share exception information resulting in uncaught exception. If -static is added than only one static copy of libgcc is linked and the exception is caught. Could the compiler enforce If you link to static libgcc, you should also link libstdc++ statically or at least warn about it? It would save users such mysterious bugs resulting from having two copies of ligcc around. Yaron 2014-08-25 11:23 GMT+03:00 Ruben Van Boxem vanboxem.ru...@gmail.com: 2014-08-24 23:48 GMT+02:00 Yaron Keren yaron.ke...@gmail.com: Hi Tai, Thanks for looking into this. You are correct the right frontend should be used, however this isn't the root of the problem. It works since g++ defaults to -shared-libgcc while gcc defaults to -static-libgcc. If you force g++ to static link libgcc, the exception is still uncaught: g++ -static-libgcc a.cpp -lstdc++ a Yaron If you link to static libgcc, you should also link libstdc++ statically. It would make no sense to do otherwise. A shortcut for all this would be to use -static, but this will also force you to use static versions of all other libraries you link, which may or may not be what you want. Ruben 2014-08-25 0:18 GMT+03:00 Kai Tietz ktiet...@googlemail.com: Hi Yaron, I can't reproduce your reported issue by using proper frontends. You shouldn't use gcc frontend. Instead use g++. Later automatically adds proper link-libraries for c++ automatically. So you don't need to add -lstdc++ manual. By using 'g++ -o a a.cpp ./a' it works for me as expected. Kai -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] exceptions weirdness
On 8/25/2014 16:50, Yaron Keren wrote: Hi Ruben, Thanks for pointing this out, the problem is indeed that libstdc++ is linked to the dynamic ligcc while the program (as above) links to the static version of libgcc. There are two seperate copies of libgcc that do not share exception information resulting in uncaught exception. If -static is added than only one static copy of libgcc is linked and the exception is caught. Could the compiler enforce If you link to static libgcc, you should also link libstdc++ statically or at least warn about it? It would save users such mysterious bugs resulting from having two copies of ligcc around. Unfortunately, no, binutils doesn't have any notion of what the input files to the linker mean. Doesn't stop users from doing it though. signature.asc Description: OpenPGP digital signature -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] exceptions weirdness
JonY jo...@users.sourceforge.net writes: Could the compiler enforce If you link to static libgcc, you should also link libstdc++ statically or at least warn about it? It would save users such mysterious bugs resulting from having two copies of ligcc around. Unfortunately, no, binutils doesn't have any notion of what the input files to the linker mean. g++ knows everything and is what users invoke for linking. Doesn't stop users from doing it though. -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] exceptions weirdness
Hi Yaron, I can't reproduce your reported issue by using proper frontends. You shouldn't use gcc frontend. Instead use g++. Later automatically adds proper link-libraries for c++ automatically. So you don't need to add -lstdc++ manual. By using 'g++ -o a a.cpp ./a' it works for me as expected. Kai -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] exceptions weirdness
Hi Tai, Thanks for looking into this. You are correct the right frontend should be used, however this isn't the root of the problem. It works since g++ defaults to -shared-libgcc while gcc defaults to -static-libgcc. If you force g++ to static link libgcc, the exception is still uncaught: g++ -static-libgcc a.cpp -lstdc++ a Yaron 2014-08-25 0:18 GMT+03:00 Kai Tietz ktiet...@googlemail.com: Hi Yaron, I can't reproduce your reported issue by using proper frontends. You shouldn't use gcc frontend. Instead use g++. Later automatically adds proper link-libraries for c++ automatically. So you don't need to add -lstdc++ manual. By using 'g++ -o a a.cpp ./a' it works for me as expected. Kai -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] exceptions weirdness
Using i686-4.9.1-release-win32-dwarf-rt_v3-rev0.7z on Windows 7 64 bit, with this simple code: #include stdio.h struct stype { ~stype() {} }; void t() { stype s; throw 1; } int main() { try { t(); } catch (...) { puts(Caught); } } When compiling with: gcc a.cpp -lstdc++ a the exception is not caught but gcc -shared-libgcc a.cpp -lstdc++ a does work. I know that -shared-libgcc is needed for exceptions to work between modules, but this is the same module... Also, if the stype class is deleted then both compile lines work. Any idea what is happening? Yaron -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public