Why. By not having an exception specification, the function is free to throw
any exception.
I don't understand what your point is.
I think that when you specify throw (Foo) in java, you're only making a
guarantee about checked exceptions (you can still throw any unchecked
exception)
Because the compiler is a little prejudiced against enforcing things across
translation units.
It doesn't need anything to be enforced across translation units. The following need
to be enforced:
(1) if a function uses the throw () keyword to throw a checked exception, it must
either (a) use an exception specification, or (b) a try/catch block
(2) the caller of a function that is declared with an exception specification is
required to either (a) specify the same exception , or (b) use a try/catch block
to catch it in that stack frame.
None of this requires anything to be enforced across translation units. The point is
that the declaration (but not necessarily the definition) of the callee appears in
the translation unit that calls it, and if the callee did not use a catch block, the
declaration includes an exception specification. So the caller's translation unit
is free to remain blissfully ignorant about the callees translation unit.
Of course you have various issues that arise when the function is declared with
different exception specifications in the different translation units. In that case,
you either need exception specs in the ABI, or you need to (in the true spirit
of C++) yell "Ouch! Don't do that!"
Cheers,