I've got one project that is compiled to a library (static .lib or dynamic .dll), which is compiled with C++ exceptions enabled. Then I've got another, separate project, that I have no control over, where exceptions are disabled, and that project links to the library that has exceptions enabled (and obviously uses classes and functions from the library that it's linking in).
To clarify:
- Library (static or dynamic, let's say .lib file): Compiled with exceptions enabled (C++ compiler flag). The library can throw but can catch all its exceptions so I can make it so that it would not leak any exceptions to the "outside"
- Project: It has exceptions disabled via compiler flag, and I cannot change this. This project links against the library above.
Is this a supported scenario or does that result in undefined behavior or something like that? Let's assume that inside the .lib, I catch all exceptions that could possibly occur and handle them, and no exceptions are "leaked" or thrown out of the .lib back into the project that does not have exceptions enabled.
Does it depend on the platform (Win/Linux/macOS etc.) or compiler (MSVC/clang/gcc) whether this works? Does it depend on whether the library is created and linked as static or dynamic library?
If it matters, the projects are compiled in C++14 mode.
This question is somewhat related, it basically says "Don't allow exceptions to propagate between two pieces of code" (unless they have the exact same compiler flags). But it doesn't specifically answer my question, which is, given I catch all exceptions (so none should cross boundaries, in theory), to link together an exception-enabled library to an exception-disabled project.