[cfe-dev] terminate called, but shouldn't be

Csaba Raduly rcsaba at gmail.com
Fri May 4 00:39:19 PDT 2012

On Thu, May 3, 2012 at 10:07 PM, Paul J. Lucas  wrote:
> On May 3, 2012, at 12:20 PM, Eric Christopher wrote:
>> On May 3, 2012, at 11:18 AM, "Paul J. Lucas"  wrote:
>>> Given this program:
>>>> #include <stdexcept>
>>>> #include <iostream>
>>>> using namespace std;
>>>> int main() {
>>>> try {
>>>>   throw std::runtime_error( "whoops!" );
>>>> }
>>>> catch ( std::exception const &e ) {
>>>>   cout << e.what() << endl;
>>>> }
>>>> return 0;
>>>> }
>>> and compiled with g++ under cygwin, I get only the output "whoops!" as expected.  When compiled with clang++ 3.0 under MinGW, I get:
>>>> terminate called after throwing an instance of 'std::runtime_error'
>>>> what():  whoops!
>>>> This application has requested the Runtime to terminate it in an unusual way.
>>>> Please contact the application's support team for more information.
>>> Why?  terminate should NOT be called since the exception is caught.
>> With ToT clang on darwin it works fine.
> As nice at that is, I also need to have code compile and execute as expected under Windows.

Then maybe you should try the Cygwin package of clang:

$ clang++ -v -Wall -pedantic -W exc.cc
clang version 3.1 (trunk 146969)
Target: i386-pc-cygwin
Thread model: posix
 "/home/csaba/bin/clang" -cc1 -triple i386-pc-cygwin -S -disable-free
-main-file-name exc.cc -mrelocation-model static -mdisable-fp-elim
-mconstructor-aliases -target-cpu pentium4 -target-linker-version -momit-leaf-frame-pointer -v -resource-dir
/home/csaba/bin/../lib/clang/3.1 -fmodule-cache-path
/var/tmp/clang-module-cache -Wall -W -pedantic -fdeprecated-macro
-fno-dwarf-directory-asm -fdebug-compilation-dir /tmp -ferror-limit 19
-fmessage-length 184 -mstackrealign -fno-use-cxa-atexit -fgnu-runtime
-fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi
-fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o
/cygdrive/c/Users/csaba/AppData/Local/Temp/exc-EQXgtP.s -x c++ exc.cc
clang -cc1 version 3.1 based upon llvm 3.1svn default target i386-pc-cygwin

$ ./a.exe

GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

More information about the cfe-dev mailing list