public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65174] New: noexcept() returns true when operator delete with the object that has a throwing destructor
@ 2015-02-23 13:28 redboltz at gmail dot com
  2015-02-23 15:37 ` [Bug c++/65174] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: redboltz at gmail dot com @ 2015-02-23 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65174

            Bug ID: 65174
           Summary: noexcept() returns true when operator delete with the
                    object that has a throwing destructor
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redboltz at gmail dot com

==========================================================================
Summary:
noexcept() returns true unexpectedly when the following conditions are
satisfied:
  1. noexcept argument expression is 'delete'.
  2. The argument of delete is the pointer literal that type has throwing
     destructor.
  3. The value of the pointer literal is null.
--------------------------------------------------------------------------
Test code: test.cpp
--------------------------------------------------------------------------
#include <iostream>

struct foo {
    ~foo() throw(std::bad_alloc) {}
};

int main() {
    std::cout << std::boolalpha;
    std::cout << noexcept(delete static_cast<foo*>(nullptr)) << std::endl;
    std::cout << noexcept(delete reinterpret_cast<foo*>(0)) << std::endl;
    std::cout << noexcept(delete reinterpret_cast<foo*>(1)) << std::endl;
}
--------------------------------------------------------------------------
Compile command:
g++ -Wall -Wextra -std=c++11 noexcept.cpp
--------------------------------------------------------------------------
Expected output:
false
false
false
--------------------------------------------------------------------------
Actual output:
true
true
false
--------------------------------------------------------------------------
gcc -v                                                                          
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-4.9-20150204/configure
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --enable-multilib
--disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20150204 (prerelease) (GCC) 
==========================================================================


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

end of thread, other threads:[~2021-08-27 17:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23 13:28 [Bug c++/65174] New: noexcept() returns true when operator delete with the object that has a throwing destructor redboltz at gmail dot com
2015-02-23 15:37 ` [Bug c++/65174] " redi at gcc dot gnu.org
2015-02-23 15:39 ` redi at gcc dot gnu.org
2021-08-27 17:44 ` [Bug c++/65174] noexcept() returns true when operator delete with a NULL PTR " pinskia at gcc dot gnu.org

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).