Bug 45657 - Wrongly computed exception specification for destructor
Summary: Wrongly computed exception specification for destructor
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.1
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2010-09-13 15:34 UTC by Johannes Schaub
Modified: 2010-09-13 18:35 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build:
Known to work: 4.6.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Schaub 2010-09-13 15:34:35 UTC
This code is invalid, but is accepted by GCC:

// snip
struct Viral {
  struct Dose { };
protected:
  ~Viral() throw (Dose) { }
};

struct Base : virtual Viral {
  virtual ~Base() throw() { }
};

struct Derived : Base { };
// snap

~Derived calls ~Viral, which adds "Dose" to its exception spec. This yields to a looser exception spec for ~Derived than for the overridden ~Base, which should yield to an ill-formed program.
Comment 1 Jonathan Wakely 2010-09-13 16:55:46 UTC
Not a regression, and G++ 4.6 correctly rejects it:

pr.cc:12:8: error: looser throw specifier for 'virtual Derived::~Derived() throw (Viral::Dose)'
pr.cc:9:11: error:   overriding 'virtual Base::~Base() throw ()'

EDG (Comeau online) also accepts it.
Comment 2 Johannes Schaub 2010-09-13 17:02:45 UTC
Great(In reply to comment #1)
> Not a regression, and G++ 4.6 correctly rejects it:
> 
> pr.cc:12:8: error: looser throw specifier for 'virtual Derived::~Derived()
> throw (Viral::Dose)'
> pr.cc:9:11: error:   overriding 'virtual Base::~Base() throw ()'
> 
> EDG (Comeau online) also accepts it.
> 

Great, thanks for checking on 4.6. Can we mark it as resolved?
Comment 3 Jonathan Wakely 2010-09-13 17:06:37 UTC
Jason, do you know if this was fixed as part of your noexcept work, or is it still latent in trunk?
Comment 4 Jason Merrill 2010-09-13 18:35:19 UTC
I'm sure this was fixed by my work on implicitly deleted functions, which involved rewriting the calculation of exception specifications for implicitly declared functions.