News for hackers. Stuff that matters.
Re:When noexcept? by youdounderstand on Thursday December 15, 2016 @11:43AM (#13185879)
Good luck when your program is dynamically linked to a library built with a different version of STL.
Re:When noexcept? by brandmeyer on Thursday December 15, 2016 @12:22PM (#13186256)
Wouldn't this run afoul of the ODR, anyway?
Re:When noexcept? by blub on Thursday December 15, 2016 @03:48PM (#13188251)
I don't think so, ODR applies per program, the library and main program are separate.

Object layouts will be likely different and the main program will probably crash.

Re:When noexcept? by brandmeyer on Thursday December 15, 2016 @04:31PM (#13188615)
Not so: The Standard doesn't have anything to say about the differences between static and dynamic libraries, or the differences between a .exe and its .dll's (or .so's). The program is composed of all the things that link into it as far as the ODR is concerned.

The breakage from mixing different library versions (say, MSVCRT versions, for example) is a direct result of violating the ODR.

Re:When noexcept? by blub on Friday December 16, 2016 @03:09AM (#13191814)
The standard doesn't say anything at all about dynamic linking AFAIK, so it's basically OS-dependent. I think it works (as in the algorithm is well defined) in Linux, but it's best avoided due to complexity and non-portability.
Re:When noexcept? by blub on Thursday December 15, 2016 @03:47PM (#13188236)
Exceptions or STL classes shouldn't cross library boundaries though, otherwise things will break.
Re:When noexcept? by gpderetta on Thursday December 15, 2016 @08:06PM (#13190250)
It will work perfectly fine as long as the libraries use compatible ABIs.

Make sure that your compiler provides a stable std library ABI.

Re:When noexcept? by blub on Friday December 16, 2016 @03:19AM (#13191847)
Good point that it's technically doable.

Is this done a lot in practice? I had the impression that a lot of projects stick to C APIs in dynamic libraries.

Re:When noexcept? by gpderetta on Friday December 16, 2016 @05:00AM (#13192211)
MSVC does not guarantee a stable standard library ABI, so those that need to target it are out of luck. In linux land, the switch from libstdc++5 to 6 still haunt the memories of many, although it was quite a long time ago (gcc 3.4) and the ABI has been stable since.

In practice the reason that many projects provide a C ABI is that they want to interoperate with other languages and the C ABI, being extremely minimalist, is the least common denominator.

Re:When noexcept? by user5994461 on Thursday December 15, 2016 @05:22PM (#13189130)
And that's why exceptions have no real world usage in C++, except for a few local functions here and there.