[Bug c++/65174] New: noexcept() returns true when operator delete with the object that has a throwing destructor
redboltz at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Feb 23 13:28:00 GMT 2015
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)
==========================================================================
More information about the Gcc-bugs
mailing list