Mir

lp:mir FTBFS: error: looser throw specifier for ‘testing::NiceMock<M>::~NiceMock()

Bug #1201246 reported by Daniel van Vugt on 2013-07-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mir
Won't Fix
Low
Unassigned
gcc
Fix Released
Medium
gcc-4.7 (Ubuntu)
Undecided
Unassigned
Nominated for Raring by Daniel van Vugt
gcc-4.8 (Ubuntu)
Undecided
Unassigned
Nominated for Raring by Daniel van Vugt

Bug Description

I know this is a gcc-4.7 (raring) bug. But I'm logging it in case we can find a workaround.

[ 48%] Building CXX object tests/mir_test_doubles/CMakeFiles/mir-test-doubles.dir/test_protobuf_client.cpp.o
In file included from /usr/include/gmock/gmock.h:62:0,
                 from /home/dan/bzr/mir/ftb/include/test/mir_test/test_protobuf_client.h:25,
                 from /home/dan/bzr/mir/ftb/tests/mir_test_doubles/test_protobuf_client.cpp:19:
/usr/include/gmock/gmock-generated-nice-strict.h: In instantiation of ‘class testing::NiceMock<mir::test::doubles::MockRpcReport>’:
/usr/include/c++/4.7/type_traits:1252:2: required by substitution of ‘template<class _From1, class _To1> static decltype ((__test_aux<_To1>(declval<_From1>()), std::__sfinae_types::__one())) std::__is_convertible_helper<_From, _To, false>::__test(int) [with _From1 = _From1; _To1 = _To1; _From = testing::NiceMock<mir::test::doubles::MockRpcReport>*; _To = mir::test::doubles::MockRpcReport*] [with _From1 = testing::NiceMock<mir::test::doubles::MockRpcReport>*; _To1 = mir::test::doubles::MockRpcReport*]’
/usr/include/c++/4.7/type_traits:1258:70: required from ‘constexpr const bool std::__is_convertible_helper<testing::NiceMock<mir::test::doubles::MockRpcReport>*, mir::test::doubles::MockRpcReport*, false>::value’
/usr/include/c++/4.7/type_traits:1263:12: required from ‘struct std::is_convertible<testing::NiceMock<mir::test::doubles::MockRpcReport>*, mir::test::doubles::MockRpcReport*>’
/usr/include/c++/4.7/bits/shared_ptr.h:216:31: required from here
/usr/include/gmock/gmock-generated-nice-strict.h:166:11: error: looser throw specifier for ‘testing::NiceMock<M>::~NiceMock() [with MockClass = mir::test::doubles::MockRpcReport]
In file included from /home/dan/bzr/mir/ftb/tests/mir_test_doubles/test_protobuf_client.cpp:20:0:
/home/dan/bzr/mir/ftb/include/test/mir_test_doubles/mock_rpc_report.h:38:5: error: overriding ‘virtual mir::test::doubles::MockRpcReport::~MockRpcReport() noexcept (true)’
make[2]: *** [tests/mir_test_doubles/CMakeFiles/mir-test-doubles.dir/test_protobuf_client.cpp.o] Error 1
make[1]: *** [tests/mir_test_doubles/CMakeFiles/mir-test-doubles.dir/all] Error 2
make: *** [all] Error 2

Related branches

... let's try this new Bugzilla ;)

This is an internal reminder that it would be nice to have implemented quite soon the resolution of core/1123:

  http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1123

For sure the library would immediately benefit, no more explicitly noexcept destructors in a lot of places.

Created attachment 26711
A testcase for N3204

Attached a testcase for N3204 ;)

In , Redi (redi) wrote :

We don't want front-end testcases that rely on <iostream> and need to check what gets printed. A better test would use static_assert, but would also test cases with both throwing and non-throwing base class and members.

Created attachment 26721
A updated testcase

OK, here is a take two!

Jason, I'm glad to work on this (if you don't have anything better to do ;) Any tips for me? Shouldn't be so hard but I'm still a bit lost...

Of course I meant "if you have something better to do ;)"

I'm making some progress understanding these parts of the front-end.

For example the following trivial patchlet passes the testcase ;) But, seriously, I'm not sure whether we really need a full fledged build_exception_variant, whether we have to do something about LAZY_* things, and much, much, more.

Index: class.c
===================================================================
--- class.c (revision 185722)
+++ class.c (working copy)
@@ -1001,6 +1001,10 @@ add_method (tree type, tree method, tree using_dec
                   "destructor",
                   type);
        }
+ else if (cxx_dialect >= cxx0x
+ && !TYPE_RAISES_EXCEPTIONS (TREE_TYPE (method)))
+ TREE_TYPE (method) = build_exception_variant (TREE_TYPE (method),
+ noexcept_true_spec);
     }
   else
     {

This doesn't compile, for example:

struct B
{
  ~B();
};

B::~B() { }

The latter issue could be addressed by something like:

Index: decl.c
===================================================================
--- decl.c (revision 185715)
+++ decl.c (working copy)
@@ -1136,7 +1136,10 @@ check_redeclaration_exception_specification (tree
   if ((pedantic || ! DECL_IN_SYSTEM_HEADER (old_decl))
       && ! DECL_IS_BUILTIN (old_decl)
       && flag_exceptions
- && !comp_except_specs (new_exceptions, old_exceptions, ce_normal))
+ && !comp_except_specs (new_exceptions, old_exceptions, ce_normal)
+ && !(DECL_DESTRUCTOR_P (new_decl)
+ && cxx_dialect >= cxx0x
+ && !new_exceptions && TYPE_NOEXCEPT_P (old_type)))
     {
       error ("declaration of %qF has a different exception specifier",
       new_decl);

Author: paolo
Date: Mon Apr 2 00:13:30 2012
New Revision: 186058

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186058
Log:
/cp
2012-04-01 Paolo Carlini <email address hidden>

 PR c++/50043
 * class.c (deduce_noexcept_on_destructor,
 deduce_noexcept_on_destructors): New.
 (check_bases_and_members): Call the latter.
 * decl.c (grokfndecl): Call the former.
 * method.c (implicitly_declare_fn): Not static.
 * cp-tree.h (deduce_noexcept_on_destructor, implicitly_declare_fn):
 Declare

/testsuite
2012-04-01 Paolo Carlini <email address hidden>

 PR c++/50043
 * g++.dg/cpp0x/noexcept17.C: New.
 * g++.old-deja/g++.eh/cleanup1.C: Adjust.
 * g++.dg/tree-ssa/ehcleanup-1.C: Likewise.
 * g++.dg/cpp0x/noexcept01.C: Likewise.
 * g++.dg/eh/init-temp1.C: Likewise.
 * g++.dg/eh/ctor1.C: Likwise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/noexcept17.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/method.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/noexcept01.C
    trunk/gcc/testsuite/g++.dg/eh/ctor1.C
    trunk/gcc/testsuite/g++.dg/eh/init-temp1.C
    trunk/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C
    trunk/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C

Done. Library clean-ups will follow.

*** Bug 51295 has been marked as a duplicate of this bug. ***

In , Redi (redi) wrote :

*** Bug 53613 has been marked as a duplicate of this bug. ***

How about back port this patch to 4.7 branch?
It cause a lot of compile error which easily confuse programmers.

(In reply to comment #9)
> Author: paolo
> Date: Mon Apr 2 00:13:30 2012
> New Revision: 186058
>
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186058
> Log:
> /cp
> 2012-04-01 Paolo Carlini <email address hidden>
>
> PR c++/50043
> * class.c (deduce_noexcept_on_destructor,
> deduce_noexcept_on_destructors): New.
> (check_bases_and_members): Call the latter.
> * decl.c (grokfndecl): Call the former.
> * method.c (implicitly_declare_fn): Not static.
> * cp-tree.h (deduce_noexcept_on_destructor, implicitly_declare_fn):
> Declare
>
> /testsuite
> 2012-04-01 Paolo Carlini <email address hidden>
>
> PR c++/50043
> * g++.dg/cpp0x/noexcept17.C: New.
> * g++.old-deja/g++.eh/cleanup1.C: Adjust.
> * g++.dg/tree-ssa/ehcleanup-1.C: Likewise.
> * g++.dg/cpp0x/noexcept01.C: Likewise.
> * g++.dg/eh/init-temp1.C: Likewise.
> * g++.dg/eh/ctor1.C: Likwise.
>
> Added:
> trunk/gcc/testsuite/g++.dg/cpp0x/noexcept17.C
> Modified:
> trunk/gcc/cp/ChangeLog
> trunk/gcc/cp/class.c
> trunk/gcc/cp/cp-tree.h
> trunk/gcc/cp/decl.c
> trunk/gcc/cp/method.c
> trunk/gcc/testsuite/ChangeLog
> trunk/gcc/testsuite/g++.dg/cpp0x/noexcept01.C
> trunk/gcc/testsuite/g++.dg/eh/ctor1.C
> trunk/gcc/testsuite/g++.dg/eh/init-temp1.C
> trunk/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C
> trunk/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C

I have tested to apply this patch to 4.7 branch, everythings goes well.
Since it breaks already existing code, anybody can do commit backport to 4.7 branch?

(In reply to comment #13)
> How about back port this patch to 4.7 branch?
> It cause a lot of compile error which easily confuse programmers.
> (In reply to comment #9)
> > Author: paolo
> > Date: Mon Apr 2 00:13:30 2012
> > New Revision: 186058
> >
> > URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186058
> > Log:
> > /cp
> > 2012-04-01 Paolo Carlini <email address hidden>
> >
> > PR c++/50043
> > * class.c (deduce_noexcept_on_destructor,
> > deduce_noexcept_on_destructors): New.
> > (check_bases_and_members): Call the latter.
> > * decl.c (grokfndecl): Call the former.
> > * method.c (implicitly_declare_fn): Not static.
> > * cp-tree.h (deduce_noexcept_on_destructor, implicitly_declare_fn):
> > Declare
> >
> > /testsuite
> > 2012-04-01 Paolo Carlini <email address hidden>
> >
> > PR c++/50043
> > * g++.dg/cpp0x/noexcept17.C: New.
> > * g++.old-deja/g++.eh/cleanup1.C: Adjust.
> > * g++.dg/tree-ssa/ehcleanup-1.C: Likewise.
> > * g++.dg/cpp0x/noexcept01.C: Likewise.
> > * g++.dg/eh/init-temp1.C: Likewise.
> > * g++.dg/eh/ctor1.C: Likwise.
> >
> > Added:
> > trunk/gcc/testsuite/g++.dg/cpp0x/noexcept17.C
> > Modified:
> > trunk/gcc/cp/ChangeLog
> > trunk/gcc/cp/class.c
> > trunk/gcc/cp/cp-tree.h
> > trunk/gcc/cp/decl.c
> > trunk/gcc/cp/method.c
> > trunk/gcc/testsuite/ChangeLog
> > trunk/gcc/testsuite/g++.dg/cpp0x/noexcept01.C
> > trunk/gcc/testsuite/g++.dg/eh/ctor1.C
> > trunk/gcc/testsuite/g++.dg/eh/init-temp1.C
> > trunk/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C
> > trunk/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C

Changed in gcc-defaults (Ubuntu):
status: New → Fix Released
Daniel van Vugt (vanvugt) wrote :

Workaround:

Edit: include/gmock/gmock-generated-nice-strict.h and change:
  virtual ~NiceMock() {
to:
  virtual ~NiceMock() noexcept {

Daniel van Vugt (vanvugt) wrote :

And that's why it's a bad idea to live on the edge of language specs. Compilers will always be several years behind and/or incomplete/buggy in their implementation. :(

Daniel van Vugt (vanvugt) wrote :

Sorry, ignore that workaround. It only works if you do it halfway through the build. It will only cause new problems if you rebuild.

Daniel van Vugt (vanvugt) wrote :

Real workaround for raring; install gcc-4.8:
  sudo apt-add-repository https://launchpad.net/~ubuntu-toolchain-r/+archive/test
  sudo apt-get update
  sudo apt-get install g++-4.8
  cmake .. -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8

Changed in gcc:
importance: Unknown → Medium
status: Unknown → Fix Released
tags: added: portability
Matthias Klose (doko) on 2013-07-15
affects: gcc-defaults (Ubuntu) → gcc-4.8 (Ubuntu)
kevin gunn (kgunn72) on 2013-07-15
Changed in mir:
importance: Undecided → Low
status: New → Triaged
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-4.7 - 4.7.3-6ubuntu1

---------------
gcc-4.7 (4.7.3-6ubuntu1) saucy; urgency=low

  * Merge with Debian; remaining changes:
    - Build from upstream source.

gcc-4.7 (4.7.3-6) unstable; urgency=low

  * Update to SVN 20130715 (r200955) from the gcc-4_7-branch.

  [ Matthias Klose ]
  * Fall back to the binutils version of the binutils build dependency
    if the binutils version used for the build cannot be determined.
  * For ARM multilib builds, use libsf/libhf system directories to lookup
    files for the non-default multilib (for now, only for the cross compilers).
  * Fix documentation builds with texinfo-5.1.
  * Update the Linaro support to the 4.7-2013.07 release.
  * Backport PR c++/50043 from the 4.8 branch. LP: #1201246.

  [ Aurelien Jarno ]
  * Don't pass --with-mips-plt on mips/mipsel.
  * Add 32-bit biarch packages on sparc64.
 -- Matthias Klose <email address hidden> Mon, 15 Jul 2013 15:11:30 +0200

Changed in gcc-4.7 (Ubuntu):
status: New → Fix Released
Changed in mir:
status: Triaged → Won't Fix
In , Redi (redi) wrote :

*** Bug 61067 has been marked as a duplicate of this bug. ***

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.