Breaking Changes Introduced in C 11
C 11 introduces several breaking changes that can cause previously valid code to fail during compilation. One notable change is the introduction of the explicit operator bool() in the standard library, replacing instances of operator void*(). While this change primarily affects invalid code that relied on implicit conversions, it still constitutes a breaking change.
Core Language Changes
- Keywords alignas, alignof, char16_t, char32_t, constexpr, decltype, noexcept, nullptr, static_assert, and thread_local are introduced.
- Integer literals larger than long may now be treated as signed long long instead of unsigned integers.
- Division now always rounds towards 0, unlike C 2003, which could round towards negative infinity in some cases.
- The auto keyword can no longer be used as a storage class specifier, as it is reserved for a new feature.
- Narrowing conversions cause incompatibilities. For example, assigning a double to an int is now invalid.
- Implicit special member functions are defined as deleted when their explicit definition would be ill-formed, resulting in errors in previously valid code.
- User-declared destructors have an implicit exception specification (noexcept(true)), which can trigger different behavior in catch blocks.
- The export keyword is no longer valid in C 11.
- Operators >> can now be used to close two templates, potentially affecting code that used the sequence >> as the shift operator.
- Dependent calls of functions with internal linkage are now allowed.
Library Changes
- Standard library identifiers introduced in C 11 may conflict with user-defined identifiers.
- Header includes that refer to new headers in the C 11 standard library may fail to compile.
- The swap function has been moved from to .
- The posix global namespace is now reserved.
- Macros override, final, carries_dependency, and noreturn are no longer valid.
The above is the detailed content of What Breaking Changes Did C 11 Introduce?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn