On Thursday 14 May 2015 09:33:59 Olivier Goffart wrote: > On Thursday 14. May 2015 08:48:36 Thiago Macieira wrote: > > On Thursday 14 May 2015 02:15:54 Marc Mutz wrote: [...] > > > The standard doesn't talk about DLLs and SOs. Semantics of those > > > constructs is supplied by the platform ABI, not std-C++. > > > > Right. > > Allow me to disagree! > > The standard C++ defines all the semantics of the code unless it defines it > as implementation-defined or undefined behaviour. > The ABI is just an implementation detail and cannot overwrite the C++ > standards.
Similar example to DLLs: Multithreading. The C++98 standard didn't talk about multithreading. So a standards-conforming function could just say int refCount; void ref() { ++refCount; } bool deref() { return --refCount; } The standard guarantees that ++x turns x into x+1 (assuming no overflow occurs), and -- turnx x into x-1. It says that int -> bool conversion exists and that the conversion result is (x != 0). So you can prove that in the above code, deref() return true whenever it has been called as many times as ref() has been before it (assuming refCount == 0 initially) - the basis of ref- counting. Enter MT, and none of the three guarantees above are valid anymore. You have entered a realm outside std-C++. So you do when using DLLs, too. C++11 talks about MT, so the above code gets what it deserves when ref() or deref() are called from more than one thread: UB. Maybe modules will make comparing addresses of inline functions across DLL boundaries UB. I don't see a difference between the two examples. Thanks, Marc -- Marc Mutz <marc.m...@kdab.com> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company Tel: +49-30-521325470 KDAB - The Qt Experts _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development