According to the spec, you can't assign the value of a less-restrictive function pointer to a more-restrictive function pointer.
Relevant C++ Spec section: 15.4 -3- (except.spec) ============================================================== Code below taken directly from the C++ spec above. ============================================================== class A { /* ... */ }; void (*pf1)(); // no exception specification void (*pf2)() throw(A); void f() { pf1 = pf2; // OK: pf1 is less restrictive pf2 = pf1; // error: pf2 is more restrictive } ============================================================== this compiles OK - it shouldn't. the line marked // error: does not produce an error. ============================================================== I ran through g++ under kdbg on a 1-line file: void (*fp)() throw(int); I'm not sure if I read it right but it seems that gcc just ignores function pointer exception specifications altogether. in gcc/cp/decl.c, in the behemoth that is grokdeclarator() which builds the declarator. there's this "tree" called "raises" that gets passed the exception spec, but it's only used to check for errors, it's not embedded into the newly built declarator. gcc/cp/decl.c :: grokdeclarator() :: ======================================= ~8100: raises = declarator->u.function.exception_specification; raises gets passed the spec. ~9172: decl = grokvardecl(.....); ..... (nothing important). ~9225: return decl; grokvardecl builds the decl that's returned, but it's not passed "raises". ======================================= "tree"'s are still confusing me so I'm not sure if it's possible to embed this into the decl without breaking anything, but that'd be where I'd start (after I was sure it wasn't already in there). when -fdumping-tree-original, there's no exception spec for the function ptr, but I guess it could've been stripped. (checked buglist for "function pointer exception specification", didn't see any dupes) -- Summary: function pointer exception specification not checked during assignment Product: gcc Version: 4.2.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yacwroy at gmail dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38069