[cfe-dev] Problem with new C++17 noexcept rules
Richard Smith via cfe-dev
cfe-dev at lists.llvm.org
Wed Nov 2 16:19:21 PDT 2016
I fixed this in r285779.
On Sat, Oct 29, 2016 at 8:50 AM, Pavel A. Lebedev via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> Hi.
>
> Since r284549 'DR1330: instantiate exception-specifications when "needed"'
> clang rejects the following:
>
> $ cat d.cpp
>
> struct S
> {
> ~S();
> void f(const S& s = S());
> };
> S::~S() {}
>
> $ clang++ -std=c++1z -fno-exceptions -fsyntax-only d.cpp
>
> d.cpp:6:4: error: conflicting types for '~S'
> S::~S() {}
> ^
> d.cpp:3:5: note: previous declaration is here
> ~S();
> ^
> 1 error generated.
>
> The error message is confusing (can it be improved?), but it seems
> that clang considers the definition of destructor implicitly
> noexcept(false),
> unlike declaration, since adding explicit 'noexcept' to the definition
> makes this compile again.
> As expected, this example compiles without error for C++03/11/14,
> since the commit in question is tweaking C++17-only rules.
> Also, clang accepts it if -fno-exceptions is NOT specified, so this looks
> like a bug to me.
> This is the minimal test case I was able to produce - this error only
> triggers for out-of-class destructor definitions when the class tries
> to construct its own instances in member function default arguments.
> This example was reduced from Qt, which breaks due to this pretty much
> completely
> and uses a combination of -std=c++1z and -fno-exceptions in default
> configuration
> when supported.
>
> ---
> Pavel A. Lebedev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161102/08f42163/attachment.html>
More information about the cfe-dev
mailing list