[BUG] try..catch does not work if compiled with clang 8.0
Brian Inglis
Brian.Inglis@SystematicSw.ab.ca
Wed Dec 18 01:50:00 GMT 2019
On 2019-12-17 13:51, Csaba Ráduly wrote:
> On 17/12/2019 17:29, Brian Inglis wrote:
>> On 2019-12-17 02:35, Pavel Fedin wrote:
>>> I haven't upgraded for a while and today i finally decided to do so. After
>>> rebuilding by project with clang++ 8.0 i found out that try...catch construct
>>> doesn't work. The program just gets silently aborted.
>>> Switched back to old clang++ 5.0 and it works.
>>> Also an old bug which i reported some (a while) time ago persists: uncaught
>>> throw does not print anything.
>>> OS is Windows 10 x86/64.
>> It is unlikely that try/catch does not work in the general case for clang++8,
>> and your post has insufficient information to reproduce the problem.
>
> a.k.a. https://www.chiark.greenend.org.uk/~sgtatham/bugs.html#respect
Indeed!
> WJFFM
>> $ cat catcher.cpp
> #include <stdexcept>
> #include <iostream>
>
> int pitcher()
> {
> Â Â Â Â throw std::runtime_error{"Ouch"};
> }
>
> int main()
> {
> Â Â Â Â try {
> Â Â Â Â Â Â Â return pitcher();
> Â Â Â Â }
> Â Â Â Â catch (std::exception const&e) {
> Â Â Â Â Â Â Â std::cout << "Caught a " << typeid(e).name() << " - " << e.what() << '\n';
> Â Â Â Â Â Â Â return 42;
> Â Â Â Â }
> }
>
> $ g++ -v -Wall -Wpedantic -Wextra -g catcher.cpp
> $ ./a.exe
> Caught a St13runtime_error - Ouch
The report was about clang++ 8 vs 5; tweaked source to build under 5 and 8:
...
#include <typeinfo>
int pitcher()
{
throw std::runtime_error("Ouch");
}
...
but same WJFFM results:
$ clang++-5.0 -g -Og -Wpedantic -Wall -Wextra -o try-catch-stc{,.cpp}
$ ./try-catch-stc
Caught a St13runtime_error - Ouch
$ clang++-8 -g -Og -Wpedantic -Wall -Wextra -o try-catch-stc{,.cpp}
$ ./try-catch-stc
Caught a St13runtime_error - Ouch
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list