GCC 8, std::uncaught_exceptions, -std=c++17

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Everyone,

I'm trying to determine when I can use std::uncaught_exceptions().

  $ cat test.cxx
  #include <iostream>

  #ifndef __has_feature
  #  define __has_feature(x) 0
  #endif

  #if _MSC_VER >= 1900
  #  define MY_EXCEPTIONS 1
  #elif __has_feature(cxx_exceptions)
  #  define MY_EXCEPTIONS 1
  #endif

  #ifdef MY_EXCEPTIONS
  #  include <exception>
  #endif

  int main(int argc, char* argv[])
  {
  #ifdef MY_EXCEPTIONS
    std::cout << std::uncaught_exceptions() << std::endl;
  #else
    std::cout << "no std::uncaught_exceptions" << std::endl;
  #endif
    return 0;
  }

Compiling and running results in:

$ /opt/cfarm/gcc8-r257824/bin/g++ -std=c++17 test.cxx -o test.exe
$ ./test.exe
no std::uncaught_exceptions


In the real code I am working on the I need to switch from
std::uncaught_exception() to std::uncaught_exceptions(). Otherwise the
terminal fills with:

algparam.h:313:32: warning: ‘bool std::uncaught_exception()’ is
deprecated [-Wdeprecated-declarations]
   if (!std::uncaught_exception())
                                ^
In file included from
/home/guerby/opt/cfarm/gcc8-r257824/include/c++/8.0.1/new:40,
                 from
/home/guerby/opt/cfarm/gcc8-r257824/include/c++/8.0.1/ext/new_allocator.h:33,
                 from
/home/guerby/opt/cfarm/gcc8-r257824/include/c++/8.0.1/powerpc64le-unknown-linux-gnu/bits/c++allocator.h:33,
                 from
/home/guerby/opt/cfarm/gcc8-r257824/include/c++/8.0.1/bits/allocator.h:46,
                 from
/home/guerby/opt/cfarm/gcc8-r257824/include/c++/8.0.1/string:41,
                 from stdcpp.h:14,
                 from cryptlib.h:103,
                 from regtest1.cpp:6:
/home/guerby/opt/cfarm/gcc8-r257824/include/c++/8.0.1/exception:102:8:
note: declared here
   bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
        ^~~~~~~~~~~~~~~~~~
...

Any ideas about what I might be doing wrong?

Jeff




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux