public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general
@ 2011-12-06 16:58 cubbi at cubbi dot org
  2011-12-06 17:11 ` [Bug libstdc++/51438] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: cubbi at cubbi dot org @ 2011-12-06 16:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51438

             Bug #: 51438
           Summary: std::exception and derived classes are not compatible
                    with std::nested_exception and C++11 in general
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: cubbi@cubbi.org


As implemented in gcc-4.7.0_alpha20111126, struct _Nested_exception has an
implicit destructor, while std::exception and all <stdexcept> exception classes
have explicit destructors with "throw()".

Because of this, it's impossible to use std::throw_with_nested with any
exception derived from std::exception:

#include <exception>
#include <stdexcept>
int main()
{
    try {
        throw 2;
    } catch(int) {
        std::throw_with_nested(std::runtime_error("test"));
    }
}

gives compilation error:

In file included from
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-alpha20111126/include/g++-v4/exception:155:0,
                 from test.cc:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-alpha20111126/include/g++-v4/bits/nested_exception.h:
In instantiation of ‘struct std::_Nested_exception<std::runtime_error>’:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-alpha20111126/include/g++-v4/bits/nested_exception.h:126:60:
  required from ‘void std::__throw_with_nested(_Ex&&, ...) [with _Ex =
std::runtime_error]’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-alpha20111126/include/g++-v4/bits/nested_exception.h:140:7:
  required from ‘void std::throw_with_nested(_Ex) [with _Ex =
std::runtime_error]’
test.cc:8:58:   required from here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-alpha20111126/include/g++-v4/bits/nested_exception.h:78:12:
error: looser throw specifier for ‘virtual
std::_Nested_exception<std::runtime_error>::~_Nested_exception()’
In file included from test.cc:2:0:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-alpha20111126/include/g++-v4/stdexcept:122:13:
error:   overriding ‘virtual std::runtime_error::~runtime_error() throw ()’



suggested fix: remove "throw()" in <exception> and <stdexcept> in C++11 mode.
The C++11 version of class exception should have "virtual ~exception();" and
other member functions should be noexcept (per §18.8.1) and the <stdexcept>
classes should have implicit dtors (per §19.2).


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/51438] std::exception and derived classes are not compatible with std::nested_exception and C++11 in general
  2011-12-06 16:58 [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general cubbi at cubbi dot org
  2011-12-06 17:11 ` [Bug libstdc++/51438] " redi at gcc dot gnu.org
@ 2011-12-06 17:11 ` redi at gcc dot gnu.org
  2011-12-06 17:20 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-06 17:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51438

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-06
     Ever Confirmed|0                           |1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/51438] std::exception and derived classes are not compatible with std::nested_exception and C++11 in general
  2011-12-06 16:58 [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general cubbi at cubbi dot org
@ 2011-12-06 17:11 ` redi at gcc dot gnu.org
  2011-12-06 17:11 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-06 17:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51438

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-06 17:10:46 UTC ---
Or we could put noexcept on ~nested_exception()


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/51438] std::exception and derived classes are not compatible with std::nested_exception and C++11 in general
  2011-12-06 16:58 [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general cubbi at cubbi dot org
  2011-12-06 17:11 ` [Bug libstdc++/51438] " redi at gcc dot gnu.org
  2011-12-06 17:11 ` redi at gcc dot gnu.org
@ 2011-12-06 17:20 ` paolo.carlini at oracle dot com
  2011-12-06 17:48 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-06 17:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51438

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.7.0

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-06 17:19:54 UTC ---
For now, let's minimally use _GLIBCXX_NOEXCEPT everywhere on those destructors.
By the way, in case isn't clear to everybody, most (all?) of such annoyances
are ultimately due to PR50043.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/51438] std::exception and derived classes are not compatible with std::nested_exception and C++11 in general
  2011-12-06 16:58 [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general cubbi at cubbi dot org
                   ` (2 preceding siblings ...)
  2011-12-06 17:20 ` paolo.carlini at oracle dot com
@ 2011-12-06 17:48 ` paolo.carlini at oracle dot com
  2011-12-06 20:03 ` paolo at gcc dot gnu.org
  2011-12-06 20:08 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-06 17:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51438

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-06 17:48:25 UTC ---
I meant _GLIBCXX_USE_NOEXCEPT of course.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/51438] std::exception and derived classes are not compatible with std::nested_exception and C++11 in general
  2011-12-06 16:58 [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general cubbi at cubbi dot org
                   ` (3 preceding siblings ...)
  2011-12-06 17:48 ` paolo.carlini at oracle dot com
@ 2011-12-06 20:03 ` paolo at gcc dot gnu.org
  2011-12-06 20:08 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-12-06 20:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51438

--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-12-06 20:03:29 UTC ---
Author: paolo
Date: Tue Dec  6 20:03:25 2011
New Revision: 182064

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182064
Log:
2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/51438
    * libsupc++/nested_exception.h (nested_exception::~nested_exception):
    Declare noexcept.
    * libsupc++/nested_exception.cc: Adjust.
    * testsuite/18_support/nested_exception/51438.cc: New.
    * testsuite/18_support/nested_exception/throw_with_nested.cc: Adjust.
    * testsuite/18_support/nested_exception/rethrow_if_nested.cc:
    Likewise.

    * src/shared_ptr.cc: Use noexcept where appropriate.
    * include/std/system_error: Likewise.
    * include/std/functional: Likewise.
    * include/bits/shared_ptr_base.h: Likewise.
    * src/stdexcept.cc: Use _GLIBCXX_USE_NOEXCEPT where appropriate.
    * include/std/stdexcept: Likewise.
    * libsupc++/bad_cast.cc: Likewise.
    * libsupc++/bad_typeid.cc: Likewise.
    * libsupc++/eh_exception.cc: Likewise.
    * libsupc++/typeinfo: Likewise.
    * libsupc++/exception: Likewise.
    * libsupc++/eh_ptr.cc: Likewise.
    * libsupc++/bad_alloc.cc: Likewise.
    * libsupc++/exception_ptr.h: Likewise.

    * include/std/chrono: Use noexcept where appropriate.
    * src/chrono.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/18_support/nested_exception/51438.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/shared_ptr_base.h
    trunk/libstdc++-v3/include/std/chrono
    trunk/libstdc++-v3/include/std/functional
    trunk/libstdc++-v3/include/std/stdexcept
    trunk/libstdc++-v3/include/std/system_error
    trunk/libstdc++-v3/libsupc++/bad_alloc.cc
    trunk/libstdc++-v3/libsupc++/bad_cast.cc
    trunk/libstdc++-v3/libsupc++/bad_typeid.cc
    trunk/libstdc++-v3/libsupc++/eh_exception.cc
    trunk/libstdc++-v3/libsupc++/eh_ptr.cc
    trunk/libstdc++-v3/libsupc++/exception
    trunk/libstdc++-v3/libsupc++/exception_ptr.h
    trunk/libstdc++-v3/libsupc++/nested_exception.cc
    trunk/libstdc++-v3/libsupc++/nested_exception.h
    trunk/libstdc++-v3/libsupc++/typeinfo
    trunk/libstdc++-v3/src/chrono.cc
    trunk/libstdc++-v3/src/shared_ptr.cc
    trunk/libstdc++-v3/src/stdexcept.cc
   
trunk/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested.cc
   
trunk/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/51438] std::exception and derived classes are not compatible with std::nested_exception and C++11 in general
  2011-12-06 16:58 [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general cubbi at cubbi dot org
                   ` (4 preceding siblings ...)
  2011-12-06 20:03 ` paolo at gcc dot gnu.org
@ 2011-12-06 20:08 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-06 20:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51438

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-06 20:07:59 UTC ---
Done.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-12-06 20:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-06 16:58 [Bug libstdc++/51438] New: std::exception and derived classes are not compatible with std::nested_exception and C++11 in general cubbi at cubbi dot org
2011-12-06 17:11 ` [Bug libstdc++/51438] " redi at gcc dot gnu.org
2011-12-06 17:11 ` redi at gcc dot gnu.org
2011-12-06 17:20 ` paolo.carlini at oracle dot com
2011-12-06 17:48 ` paolo.carlini at oracle dot com
2011-12-06 20:03 ` paolo at gcc dot gnu.org
2011-12-06 20:08 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).