Bug 49082 - [C++0x] Issues with noexcept propagation
Summary: [C++0x] Issues with noexcept propagation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-20 15:24 UTC by Paolo Carlini
Modified: 2011-05-20 21:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-20 19:50:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo Carlini 2011-05-20 15:24:18 UTC
This is a memo for the issues with noexcept already signaled to Jason. First I noticed this, which seriously blocks library work at the moment:

#include <utility>

struct Base
{
  Base(const Base&) noexcept(false);
  Base(Base&&) noexcept(false);
};

struct Derived
: Base
{
  // Derived(const Derived&) = default;
  // Derived(Derived&&) = default;
};

static_assert(!noexcept(Base(std::declval<const Base&>())), "Error");
static_assert(!noexcept(Derived(std::declval<const Derived&>())), "Error"); // Error

static_assert(!noexcept(Base(std::declval<Base&&>())), "Error");
static_assert(!noexcept(Derived(std::declval<Derived&&>())), "Error"); // Error

Then Daniel Krugler added this:

struct Base
{
 Base(const Base&) noexcept(false);
 Base(Base&&) noexcept(false);
 ~Base() noexcept(false);
};

struct Derived
: Base
{
  Base b;
};

static_assert(!noexcept(std::declval<Base&>().~Base()), "Error"); // OK
static_assert(!noexcept(std::declval<Derived&>().~Derived()), "Error"); // Error
Comment 1 Jason Merrill 2011-05-20 20:40:03 UTC
Author: jason
Date: Fri May 20 20:39:59 2011
New Revision: 173981

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173981
Log:
	DR 1073
	PR c++/49082
	* typeck.c (comp_except_specs): noexcept(false) is not compatible
	with throw(type-list).
	* typeck2.c (merge_exception_specifiers): noexcept(false)
	beats any more limited specification.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/noexcept10.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/noexcept02.C
    trunk/gcc/testsuite/g++.dg/cpp0x/noexcept03.C
    trunk/gcc/testsuite/g++.dg/cpp0x/noexcept08.C
Comment 2 Paolo Carlini 2011-05-20 21:22:02 UTC
Thanks!
Comment 3 Jason Merrill 2011-05-20 21:29:17 UTC
Author: jason
Date: Fri May 20 21:29:14 2011
New Revision: 173984

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173984
Log:
	DR 1073
	PR c++/49082
	* typeck.c (comp_except_specs): noexcept(false) is not compatible
	with throw(type-list).
	* typeck2.c (merge_exception_specifiers): noexcept(false)
	beats any more limited specification.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/noexcept10.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/typeck.c
    branches/gcc-4_6-branch/gcc/cp/typeck2.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/noexcept02.C
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/noexcept03.C
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/noexcept08.C
Comment 4 Jason Merrill 2011-05-20 21:32:03 UTC
Fixed for 4.6.1.