4 ms·
The intent of C++ is that the subset that is valid C code ends up being largely semantically identical in C++ and C. There are some differences, particularly re
by jcranmer 8y ago
The intent of C++ is that the subset that is valid C code ends up being largely semantically identical in C++ and C. There are some differences, particularly related to the type system (for example, in C, a ternary expression is an rvalue, where it can be an lvalue expression in C++). Most, perhaps all, of the undefined behavior is retained C++.
There is potentially a case where C eliminated undefined behavior that C++ retained--the "union trick" for getting access to the bits of a float was made legal in C99 but the C++ language (modified to support unrestricted unions) suggests that it is undefined behavior in C++.