1 ===========================================
2 Clang |release| |ReleaseNotesTitle|
3 ===========================================
9 Written by the `LLVM Team <https://llvm.org/>`_
14 These are in-progress notes for the upcoming Clang |version| release.
15 Release notes for previous releases can be found on
16 `the Releases Page <https://llvm.org/releases/>`_.
21 This document contains the release notes for the Clang C/C++/Objective-C
22 frontend, part of the LLVM Compiler Infrastructure, release |release|. Here we
23 describe the status of Clang in some detail, including major
24 improvements from the previous release and new feature work. For the
25 general LLVM release notes, see `the LLVM
26 documentation <https://llvm.org/docs/ReleaseNotes.html>`_. For the libc++ release notes,
27 see `this page <https://libcxx.llvm.org/ReleaseNotes.html>`_. All LLVM releases
28 may be downloaded from the `LLVM releases web site <https://llvm.org/releases/>`_.
30 For more information about Clang or LLVM, including information about the
31 latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
32 `LLVM Web Site <https://llvm.org>`_.
34 Potentially Breaking Changes
35 ============================
36 These changes are ones which we think may surprise users when upgrading to
37 Clang |release| because of the opportunity they pose for disruption to existing
40 - The ``le32`` and ``le64`` targets have been removed.
42 - ``clang -m32`` defaults to ``-mcpu=v9`` on SPARC Linux now. Distros
43 still supporting SPARC V8 CPUs need to specify ``-mcpu=v8`` with a
45 <https://clang.llvm.org/docs/UsersManual.html#configuration-files>`_.
47 - The ``clang-rename`` tool has been removed.
49 - Removed support for RenderScript targets. This technology is
50 `officially deprecated <https://developer.android.com/guide/topics/renderscript/compute>`_
51 and users are encouraged to
52 `migrate to Vulkan <https://developer.android.com/guide/topics/renderscript/migrate>`_
55 C/C++ Language Potentially Breaking Changes
56 -------------------------------------------
58 C++ Specific Potentially Breaking Changes
59 -----------------------------------------
61 - The type trait builtin ``__is_nullptr`` has been removed, since it has very
62 few users and can be written as ``__is_same(__remove_cv(T), decltype(nullptr))``,
63 which GCC supports as well.
65 - Clang will now correctly diagnose as ill-formed a constant expression where an
66 enum without a fixed underlying type is set to a value outside the range of
67 the enumeration's values.
71 enum E { Zero, One, Two, Three, Four };
72 constexpr E Val1 = (E)3; // Ok
73 constexpr E Val2 = (E)7; // Ok
74 constexpr E Val3 = (E)8; // Now ill-formed, out of the range [0, 7]
75 constexpr E Val4 = (E)-1; // Now ill-formed, out of the range [0, 7]
77 Since Clang 16, it has been possible to suppress the diagnostic via
78 `-Wno-enum-constexpr-conversion`, to allow for a transition period for users.
79 Now, in Clang 20, **it is no longer possible to suppress the diagnostic**.
81 - Extraneous template headers are now ill-formed by default.
82 This error can be disable with ``-Wno-error=extraneous-template-head``.
86 template <> // error: extraneous template head
90 - During constant evaluation, comparisons between different evaluations of the
91 same string literal are now correctly treated as non-constant, and comparisons
92 between string literals that cannot possibly overlap in memory are now treated
93 as constant. This updates Clang to match the anticipated direction of open core
94 issue `CWG2765 <http://wg21.link/CWG2765>`, but is subject to change once that
99 constexpr const char *f() { return "hello"; }
100 constexpr const char *g() { return "world"; }
101 // Used to evaluate to false, now error: non-constant comparison.
102 constexpr bool a = f() == f();
103 // Might evaluate to true or false, as before.
104 bool at_runtime() { return f() == f(); }
105 // Was error, now evaluates to false.
106 constexpr bool b = f() == g();
108 - Clang will now correctly not consider pointers to non classes for covariance
109 and disallow changing return type to a type that doesn't have the same or less cv-qualifications.
114 virtual const int *f() const;
115 virtual const std::string *g() const;
118 // Return type has less cv-qualification but doesn't point to a class.
119 // Error will be generated.
120 int *f() const override;
122 // Return type doesn't have more cv-qualification also not the same or
123 // less cv-qualification.
124 // Error will be generated.
125 volatile std::string *g() const override;
128 - The warning ``-Wdeprecated-literal-operator`` is now on by default, as this is
129 something that WG21 has shown interest in removing from the language. The
130 result is that anyone who is compiling with ``-Werror`` should see this
131 diagnostic. To fix this diagnostic, simply removing the space character from
132 between the ``operator""`` and the user defined literal name will make the
133 source no longer deprecated. This is consistent with `CWG2521 <https://cplusplus.github.io/CWG/issues/2521.html>_`.
137 // Now diagnoses by default.
138 unsigned operator"" _udl_name(unsigned long long);
140 unsigned operator""_udl_name(unsigned long long);
142 - Clang will now produce an error diagnostic when [[clang::lifetimebound]] is
143 applied on a parameter or an implicit object parameter of a function that
144 returns void. This was previously ignored and had no effect. (#GH107556)
148 // Now diagnoses with an error.
149 void f(int& i [[clang::lifetimebound]]);
151 - Clang now rejects all field accesses on null pointers in constant expressions. The following code
152 used to work but will now be rejected:
156 struct S { int a; int b; };
157 constexpr const int *p = &((S*)nullptr)->b;
159 Previously, this code was erroneously accepted.
162 ABI Changes in This Version
163 ---------------------------
165 - Fixed Microsoft name mangling of placeholder, auto and decltype(auto), return types for MSVC 1920+. This change resolves incompatibilities with code compiled by MSVC 1920+ but will introduce incompatibilities with code compiled by earlier versions of Clang unless such code is built with the compiler option -fms-compatibility-version=19.14 to imitate the MSVC 1914 mangling behavior.
166 - Fixed the Itanium mangling of the construction vtable name. This change will introduce incompatibilities with code compiled by Clang 19 and earlier versions, unless the -fclang-abi-compat=19 option is used. (#GH108015)
167 - Mangle member-like friend function templates as members of the enclosing class. (#GH110247, #GH110503)
169 AST Dumping Potentially Breaking Changes
170 ----------------------------------------
172 Clang Frontend Potentially Breaking Changes
173 -------------------------------------------
175 Clang Python Bindings Potentially Breaking Changes
176 --------------------------------------------------
177 - Parts of the interface returning string results will now return
178 the empty string ``""`` when no result is available, instead of ``None``.
179 - Calling a property on the ``CompletionChunk`` or ``CompletionString`` class
180 statically now leads to an error, instead of returning a ``CachedProperty`` object
181 that is used internally. Properties are only available on instances.
182 - For a single-line ``SourceRange`` and a ``SourceLocation`` in the same line,
183 but after the end of the ``SourceRange``, ``SourceRange.__contains__``
184 used to incorrectly return ``True``. (#GH22617), (#GH52827)
186 What's New in Clang |release|?
187 ==============================
188 Some of the major new features and improvements to Clang are listed
189 here. Generic improvements to Clang as a whole or to its underlying
190 infrastructure are described first, followed by language-specific
191 sections with improvements to Clang's support for those languages.
195 - Allow single element access of GCC vector/ext_vector_type object to be
196 constant expression. Supports the `V.xyzw` syntax and other tidbits
197 as seen in OpenCL. Selecting multiple elements is left as a future work.
198 - Implement `CWG1815 <https://wg21.link/CWG1815>`_. Support lifetime extension
199 of temporary created by aggregate initialization using a default member
202 - Accept C++26 user-defined ``static_assert`` messages in C++11 as an extension.
204 - Add ``__builtin_elementwise_popcount`` builtin for integer types only.
206 - Add ``__builtin_elementwise_fmod`` builtin for floating point types only.
208 - Add ``__builtin_elementwise_minimum`` and ``__builtin_elementwise_maximum``
209 builtin for floating point types only.
211 - The builtin type alias ``__builtin_common_type`` has been added to improve the
212 performance of ``std::common_type``.
214 C++2c Feature Support
215 ^^^^^^^^^^^^^^^^^^^^^
217 - Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports
218 `P2647R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_
220 - Add ``__builtin_is_virtual_base_of`` intrinsic, which supports
221 `P2985R0 A type trait for detecting virtual base classes <https://wg21.link/p2985r0>`_
223 - Implemented `P2893R3 Variadic Friends <https://wg21.link/P2893>`_
225 - Implemented `P2747R2 constexpr placement new <https://wg21.link/P2747R2>`_.
227 - Added the ``__builtin_is_within_lifetime`` builtin, which supports
228 `P2641R4 Checking if a union alternative is active <https://wg21.link/p2641r4>`_
230 C++23 Feature Support
231 ^^^^^^^^^^^^^^^^^^^^^
232 - Removed the restriction to literal types in constexpr functions in C++23 mode.
234 - Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
235 supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
237 C++20 Feature Support
238 ^^^^^^^^^^^^^^^^^^^^^
241 Resolutions to C++ Defect Reports
242 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
244 - Allow calling initializer list constructors from initializer lists with
245 a single element of the same type instead of always copying.
246 (`CWG2137: List-initialization from object of same type <https://cplusplus.github.io/CWG/issues/2137.html>`)
248 - Speculative resolution for CWG2311 implemented so that the implementation of CWG2137 doesn't remove
249 previous cases where guaranteed copy elision was done. Given a prvalue ``e`` of class type
250 ``T``, ``T{e}`` will try to resolve an initializer list constructor and will use it if successful.
251 Otherwise, if there is no initializer list constructor, the copy will be elided as if it was ``T(e)``.
252 (`CWG2311: Missed case for guaranteed copy elision <https://cplusplus.github.io/CWG/issues/2311.html>`)
254 - Casts from a bit-field to an integral type is now not considered narrowing if the
255 width of the bit-field means that all potential values are in the range
256 of the target type, even if the type of the bit-field is larger.
257 (`CWG2627: Bit-fields and narrowing conversions <https://cplusplus.github.io/CWG/issues/2627.html>`_)
259 - ``nullptr`` is now promoted to ``void*`` when passed to a C-style variadic function.
260 (`CWG722: Can nullptr be passed to an ellipsis? <https://cplusplus.github.io/CWG/issues/722.html>`_)
262 - Allow ``void{}`` as a prvalue of type ``void``.
263 (`CWG2351: void{} <https://cplusplus.github.io/CWG/issues/2351.html>`_).
265 - Clang now has improved resolution to CWG2398, allowing class templates to have
266 default arguments deduced when partial ordering.
268 - Clang now allows comparing unequal object pointers that have been cast to ``void *``
269 in constant expressions. These comparisons always worked in non-constant expressions.
270 (`CWG2749: Treatment of "pointer to void" for relational comparisons <https://cplusplus.github.io/CWG/issues/2749.html>`_).
272 - Reject explicit object parameters with type ``void`` (``this void``).
273 (`CWG2915: Explicit object parameters of type void <https://cplusplus.github.io/CWG/issues/2915.html>`_).
275 - Clang now allows trailing requires clause on explicit deduction guides.
276 (`CWG2707: Deduction guides cannot have a trailing requires-clause <https://cplusplus.github.io/CWG/issues/2707.html>`_).
278 - Clang now diagnoses a space in the first production of a ``literal-operator-id``
280 (`CWG2521: User-defined literals and reserved identifiers <https://cplusplus.github.io/CWG/issues/2521.html>`_).
285 - Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
290 - Updated conformance for `N3298 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3298.htm>`_
291 which adds the ``i`` and ``j`` suffixes for the creation of a ``_Complex``
292 constant value. Clang has always supported these suffixes as a GNU extension,
293 so ``-Wgnu-imaginary-constant`` no longer has effect in C modes, as this is
294 now a C2y extension in C. ``-Wgnu-imaginary-constant`` still applies in C++
297 - Clang updated conformance for `N3370 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3370.htm>`_
298 case range expressions. This feature was previously supported by Clang as a
299 GNU extension, so ``-Wgnu-case-range`` no longer has effect in C modes, as
300 this is now a C2y extension in C. ``-Wgnu-case-range`` still applies in C++
303 - Clang implemented support for `N3344 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3344.pdf>`_
304 which disallows a ``void`` parameter from having a qualifier or storage class
305 specifier. Note that ``register void`` was previously accepted in all C
306 language modes but is now rejected (all of the other qualifiers and storage
307 class specifiers were previously rejected).
309 - Updated conformance for `N3364 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3364.pdf>`_
310 on floating-point translation-time initialization with signaling NaN. This
311 paper adopts Clang's existing practice, so there were no changes to compiler
314 - Implemented support for `N3341 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3341.pdf>`_
315 which makes empty structure and union objects implementation-defined in C.
316 ``-Wgnu-empty-struct`` will be emitted in C23 and earlier modes because the
317 behavior is a conforming GNU extension in those modes, but will no longer
318 have an effect in C2y mode.
320 - Updated conformance for `N3342 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3342.pdf>`_
321 which made qualified function types implementation-defined rather than
322 undefined. Clang has always accepted ``const`` and ``volatile`` qualified
323 function types by ignoring the qualifiers.
325 - Updated conformance for `N3346 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3346.pdf>`_
326 which changes some undefined behavior around initialization to instead be
327 constraint violations. This paper adopts Clang's existing practice, so there
328 were no changes to compiler behavior.
333 - Clang now supports `N3029 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3029.htm>`_ Improved Normal Enumerations.
334 - Clang now officially supports `N3030 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3030.htm>`_ Enhancements to Enumerations. Clang already supported it as an extension, so there were no changes to compiler behavior.
336 Non-comprehensive list of changes in this release
337 -------------------------------------------------
339 - The floating point comparison builtins (``__builtin_isgreater``,
340 ``__builtin_isgreaterequal``, ``__builtin_isless``, etc.) and
341 ``__builtin_signbit`` can now be used in constant expressions.
342 - Plugins can now define custom attributes that apply to statements
343 as well as declarations.
344 - ``__builtin_abs`` function can now be used in constant expressions.
346 - The new builtin ``__builtin_counted_by_ref`` was added. In contexts where the
347 programmer needs access to the ``counted_by`` attribute's field, but it's not
348 available --- e.g. in macros. For instace, it can be used to automatically
349 set the counter during allocation in the Linux kernel:
353 /* A simplified version of Linux allocation macros */
354 #define alloc(PTR, FAM, COUNT) ({ \
355 sizeof_t __ignored_assignment; \
357 size_t __size = sizeof(*P) + sizeof(*P->FAM) * COUNT; \
358 __p = malloc(__size); \
360 __builtin_counted_by_ref(__p->FAM), \
361 void *: &__ignored_assignment, \
362 default: __builtin_counted_by_ref(__p->FAM)) = COUNT; \
366 The flexible array member (FAM) can now be accessed immediately without causing
367 issues with the sanitizer because the counter is automatically set.
369 - ``__builtin_reduce_add`` function can now be used in constant expressions.
370 - ``__builtin_reduce_mul`` function can now be used in constant expressions.
371 - ``__builtin_reduce_and`` function can now be used in constant expressions.
372 - ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be used in constant expressions.
377 - The ``-fc++-static-destructors={all,thread-local,none}`` flag was
378 added to control which C++ variables have static destructors
379 registered: all (the default) does so for all variables, thread-local
380 only for thread-local variables, and none (which corresponds to the
381 existing ``-fno-c++-static-destructors`` flag) skips all static
382 destructors registration.
384 Deprecated Compiler Flags
385 -------------------------
387 - ``-fheinous-gnu-extensions`` is deprecated; it is now equivalent to
388 specifying ``-Wno-error=invalid-gnu-asm-cast`` and may be removed in the
391 Modified Compiler Flags
392 -----------------------
394 - The ``-ffp-model`` option has been updated to enable a more limited set of
395 optimizations when the ``fast`` argument is used and to accept a new argument,
396 ``aggressive``. The behavior of ``-ffp-model=aggressive`` is equivalent
397 to the previous behavior of ``-ffp-model=fast``. The updated
398 ``-ffp-model=fast`` behavior no longer assumes finite math only and uses
399 the ``promoted`` algorithm for complex division when possible rather than the
400 less basic (limited range) algorithm.
402 - The ``-fveclib`` option has been updated to enable ``-fno-math-errno`` for
403 ``-fveclib=ArmPL`` and ``-fveclib=SLEEF``. This gives Clang more opportunities
404 to utilize these vector libraries. The behavior for all other vector function
405 libraries remains unchanged.
407 - The ``-Wnontrivial-memaccess`` warning has been updated to also warn about
408 passing non-trivially-copyable destrination parameter to ``memcpy``,
409 ``memset`` and similar functions for which it is a documented undefined
412 Removed Compiler Flags
413 -------------------------
415 - The compiler flag `-Wenum-constexpr-conversion` (and the `Wno-`, `Wno-error-`
416 derivatives) is now removed, since it's no longer possible to suppress the
417 diagnostic (see above). Users can expect an `unknown warning` diagnostic if
420 Attribute Changes in Clang
421 --------------------------
423 - The ``swift_attr`` can now be applied to types. To make it possible to use imported APIs
424 in Swift safely there has to be a way to annotate individual parameters and result types
425 with relevant attributes that indicate that e.g. a block is called on a particular actor
426 or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated parameter.
433 -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"))))(id)) handler;
436 - Clang now disallows more than one ``__attribute__((ownership_returns(class, idx)))`` with
437 different class names attached to one function.
439 - Introduced a new format attribute ``__attribute__((format(syslog, 1, 2)))`` from OpenBSD.
441 - The ``hybrid_patchable`` attribute is now supported on ARM64EC targets. It can be used to specify
442 that a function requires an additional x86-64 thunk, which may be patched at runtime.
444 - ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions
445 where they were previously silently ignored.
447 - Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of
448 ``std::span, std::string_view`` constructors, this enables Clang to capture
449 more cases where the returned reference outlives the object.
452 - Clang now correctly diagnoses the use of ``btf_type_tag`` in C++ and ignores
453 it; this attribute is a C-only attribute, and caused crashes with template
454 instantiation by accidentally allowing it in C++ in some circumstances.
457 - Introduced a new attribute ``[[clang::coro_await_elidable]]`` on coroutine return types
458 to express elideability at call sites where the coroutine is invoked under a safe elide context.
460 - Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on function parameters
461 to propagate safe elide context to arguments if such function is also under a safe elide context.
463 - The documentation of the ``[[clang::musttail]]`` attribute was updated to
464 note that the lifetimes of all local variables end before the call. This does
465 not change the behaviour of the compiler, as this was true for previous
468 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
469 ``[[gsl::Pointer]]`` to STL explicit template specialization decls. (#GH109442)
471 - Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be
472 used to specify when a reference to a function parameter is captured by another capturing entity ``X``.
474 Improvements to Clang's diagnostics
475 -----------------------------------
477 - Some template related diagnostics have been improved.
481 void foo() { template <typename> int i; } // error: templates can only be declared in namespace or class scope
484 template <typename> int i; // error: non-static data member 'i' cannot be declared as a template
487 - Clang now has improved diagnostics for functions with explicit 'this' parameters. Fixes #GH97878
489 - Clang now diagnoses dangling references to fields of temporary objects. Fixes #GH81589.
491 - Clang now diagnoses undefined behavior in constant expressions more consistently. This includes invalid shifts, and signed overflow in arithmetic.
493 - -Wdangling-assignment-gsl is enabled by default.
494 - Clang now always preserves the template arguments as written used
495 to specialize template type aliases.
497 - Clang now diagnoses the use of ``main`` in an ``extern`` context as invalid according to [basic.start.main] p3. Fixes #GH101512.
499 - Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.
501 - Don't emit duplicated dangling diagnostics. (#GH93386).
503 - Improved diagnostic when trying to befriend a concept. (#GH45182).
505 - Added the ``-Winvalid-gnu-asm-cast`` diagnostic group to control warnings
506 about use of "noop" casts for lvalues (a GNU extension). This diagnostic is
507 a warning which defaults to being an error, is enabled by default, and is
508 also controlled by the now-deprecated ``-fheinous-gnu-extensions`` flag.
510 - Added the ``-Wdecls-in-multiple-modules`` option to assist users to identify
511 multiple declarations in different modules, which is the major reason of the slow
512 compilation speed with modules. This warning is disabled by default and it needs
513 to be explicitly enabled or by ``-Weverything``.
515 - Improved diagnostic when trying to overload a function in an ``extern "C"`` context. (#GH80235)
517 - Clang now respects lifetimebound attribute for the assignment operator parameter. (#GH106372).
519 - The lifetimebound and GSL analysis in clang are coherent, allowing clang to
520 detect more use-after-free bugs. (#GH100549).
522 - Clang now diagnoses dangling cases where a gsl-pointer is constructed from a gsl-owner object inside a container (#GH100384).
524 - Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
526 - Clang now diagnose when importing module implementation partition units in module interface units.
528 - Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::lifetimebound]]` are used together (#GH108272).
530 - The ``-Wreturn-stack-address`` warning now also warns about addresses of
531 local variables passed to function calls using the ``[[clang::musttail]]``
534 - Clang now diagnoses cases where a dangling ``GSLOwner<GSLPointer>`` object is constructed, e.g. ``std::vector<string_view> v = {std::string()};`` (#GH100526).
536 - Clang now diagnoses when a ``requires`` expression has a local parameter of void type, aligning with the function parameter (#GH109831).
538 - Clang now emits a diagnostic note at the class declaration when the method definition does not match any declaration (#GH110638).
540 - Clang now omits warnings for extra parentheses in fold expressions with single expansion (#GH101863).
542 - The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``,
543 instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being
544 suboptimal in some way the error fails to mention (#GH111550).
546 - Clang now emits a ``-Wdepredcated-literal-operator`` diagnostic, even if the
547 name was a reserved name, which we improperly allowed to suppress the
550 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073).
552 - Improved diagnostic message for ``__builtin_bit_cast`` size mismatch (#GH115870).
554 - Clang now omits shadow warnings for enum constants in separate class scopes (#GH62588).
556 - When diagnosing an unused return value of a type declared ``[[nodiscard]]``, the type
557 itself is now included in the diagnostic.
559 - Clang will now prefer the ``[[nodiscard]]`` declaration on function declarations over ``[[nodiscard]]``
560 declaration on the return type of a function. Previously, when both have a ``[[nodiscard]]`` declaration attached,
561 the one on the return type would be preferred. This may affect the generated warning message:
565 struct [[nodiscard("Reason 1")]] S {};
566 [[nodiscard("Reason 2")]] S getS();
569 getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
572 - Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
574 - Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485).
576 - Clang now correctly recognises code after a call to a ``[[noreturn]]`` constructor
577 as unreachable (#GH63009).
579 - Clang now omits shadowing warnings for parameter names in explicit object member functions (#GH95707).
581 - Improved error recovery for function call arguments with trailing commas (#GH100921).
583 - For an rvalue reference bound to a temporary struct with an integer member, Clang will detect constant integer overflow
584 in the initializer for the integer member (#GH46755).
586 Improvements to Clang's time-trace
587 ----------------------------------
589 Improvements to Coverage Mapping
590 --------------------------------
592 Bug Fixes in This Version
593 -------------------------
595 - Fixed the definition of ``ATOMIC_FLAG_INIT`` in ``<stdatomic.h>`` so it can
597 - Fixed a failed assertion when checking required literal types in C context. (#GH101304).
598 - Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685.
599 - Fixed a crash when diagnosing format strings and encountering an empty
600 delimited escape sequence (e.g., ``"\o{}"``). #GH102218
601 - Fixed a crash using ``__array_rank`` on 64-bit targets. (#GH113044).
602 - The warning emitted for an unsupported register variable type now points to
603 the unsupported type instead of the ``register`` keyword (#GH109776).
604 - Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
605 - Fixed a crash when GNU statement expression contains invalid statement (#GH113468).
606 - Fixed a failed assertion when using ``__attribute__((noderef))`` on an
607 ``_Atomic``-qualified type (#GH116124).
609 Bug Fixes to Compiler Builtins
610 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
612 - Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330)
614 - Clang now allows pointee types of atomic builtin arguments to be complete template types
615 that was not instantiated elsewhere.
617 - ``__noop`` can now be used in a constant expression. (#GH102064)
619 - Fix ``__has_builtin`` incorrectly returning ``false`` for some C++ type traits. (#GH111477)
621 Bug Fixes to Attribute Support
622 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
624 Bug Fixes to C++ Support
625 ^^^^^^^^^^^^^^^^^^^^^^^^
627 - Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646)
628 - Fixed incorrect pack expansion of init-capture references in requires expresssions.
629 - Fixed a failed assertion when checking invalid delete operator declaration. (#GH96191)
630 - Fix a crash when checking destructor reference with an invalid initializer. (#GH97230)
631 - Clang now correctly parses potentially declarative nested-name-specifiers in pointer-to-member declarators.
632 - Fix a crash when checking the initialzier of an object that was initialized
633 with a string literal. (#GH82167)
634 - Fix a crash when matching template template parameters with templates which have
635 parameters of different class type. (#GH101394)
636 - Clang now correctly recognizes the correct context for parameter
637 substitutions in concepts, so it doesn't incorrectly complain of missing
638 module imports in those situations. (#GH60336)
639 - Fix init-capture packs having a size of one before being instantiated. (#GH63677)
640 - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
642 - Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
643 - Fixed an assertion failure when selecting a function from an overload set that includes a
644 specialization of a conversion function template.
645 - Correctly diagnose attempts to use a concept name in its own definition;
646 A concept name is introduced to its scope sooner to match the C++ standard. (#GH55875)
647 - Properly reject defaulted relational operators with invalid types for explicit object parameters,
648 e.g., ``bool operator==(this int, const Foo&)`` (#GH100329), and rvalue reference parameters.
649 - Properly reject defaulted copy/move assignment operators that have a non-reference explicit object parameter.
650 - Clang now properly handles the order of attributes in `extern` blocks. (#GH101990).
651 - Fixed an assertion failure by preventing null explicit object arguments from being deduced. (#GH102025).
652 - Correctly check constraints of explicit instantiations of member functions. (#GH46029)
653 - When performing partial ordering of function templates, clang now checks that
654 the deduction was consistent. Fixes (#GH18291).
655 - Fixed an assertion failure about a constraint of a friend function template references to a value with greater
656 template depth than the friend function template. (#GH98258)
657 - Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
658 of the current instantiation in all cases.
659 - Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900)
660 - Correctly handle subexpressions of an immediate invocation in the presence of implicit casts. (#GH105558)
661 - Clang now correctly handles direct-list-initialization of a structured bindings from an array. (#GH31813)
662 - Mangle placeholders for deduced types as a template-prefix, such that mangling
663 of template template parameters uses the correct production. (#GH106182)
664 - Fixed an assertion failure when converting vectors to int/float with invalid expressions. (#GH105486)
665 - Template parameter names are considered in the name lookup of out-of-line class template
666 specialization right before its declaration context. (#GH64082)
667 - Fixed a constraint comparison bug for friend declarations. (#GH78101)
668 - Fix handling of ``_`` as the name of a lambda's init capture variable. (#GH107024)
669 - Fix an issue with dependent source location expressions (#GH106428), (#GH81155), (#GH80210), (#GH85373)
670 - Fixed a bug in the substitution of empty pack indexing types. (#GH105903)
671 - Clang no longer tries to capture non-odr used default arguments of template parameters of generic lambdas (#GH107048)
672 - Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588)
673 - Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134)
674 - A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361), (#GH112352)
675 - Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)
676 - Fixed a crash when clang tries to subtitute parameter pack while retaining the parameter
677 pack. (#GH63819), (#GH107560)
678 - Fix a crash when a static assert declaration has an invalid close location. (#GH108687)
679 - Avoided a redundant friend declaration instantiation under a certain ``consteval`` context. (#GH107175)
680 - Fixed an assertion failure in debug mode, and potential crashes in release mode, when
681 diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
682 - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
683 - Fixed a crash when mixture of designated and non-designated initializers in union. (#GH113855)
684 - Fixed an issue deducing non-type template arguments of reference type. (#GH73460)
685 - Fixed an issue in constraint evaluation, where type constraints on the lambda expression
686 containing outer unexpanded parameters were not correctly expanded. (#GH101754)
687 - Fixes crashes with function template member specializations, and increases
688 conformance of explicit instantiation behaviour with MSVC. (#GH111266)
689 - Fixed a bug in constraint expression comparison where the ``sizeof...`` expression was not handled properly
690 in certain friend declarations. (#GH93099)
691 - Clang now instantiates the correct lambda call operator when a lambda's class type is
692 merged across modules. (#GH110401)
693 - Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
694 - Fixed an assertion failure when invoking recovery call expressions with explicit attributes
695 and undeclared templates. (#GH107047), (#GH49093)
696 - Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded
697 parameter pack. (#GH109148)
698 - Fixed overload handling for object parameters with top-level cv-qualifiers in explicit member functions (#GH100394)
699 - Fixed a bug in lambda captures where ``constexpr`` class-type objects were not properly considered ODR-used in
700 certain situations. (#GH47400), (#GH90896)
701 - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441)
702 - During the lookup for a base class name, non-type names are ignored. (#GH16855)
703 - Fix a crash when recovering an invalid expression involving an explicit object member conversion operator. (#GH112559)
704 - Clang incorrectly considered a class with an anonymous union member to not be
705 const-default-constructible even if a union member has a default member initializer.
707 - Fixed an assertion failure when evaluating an invalid expression in an array initializer. (#GH112140)
708 - Fixed an assertion failure in range calculations for conditional throw expressions. (#GH111854)
709 - Clang now correctly ignores previous partial specializations of member templates explicitly specialized for
710 an implicitly instantiated class template specialization. (#GH51051)
711 - Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208)
712 - Name independent data members were not correctly initialized from default member initializers. (#GH114069)
713 - Fixed expression transformation for ``[[assume(...)]]``, allowing using pack indexing expressions within the
714 assumption if they also occur inside of a dependent lambda. (#GH114787)
715 - Clang now uses valid deduced type locations when diagnosing functions with trailing return type
716 missing placeholder return type. (#GH78694)
718 Bug Fixes to AST Handling
719 ^^^^^^^^^^^^^^^^^^^^^^^^^
721 - Fixed a crash that occurred when dividing by zero in complex integer division. (#GH55390).
722 - Fixed a bug in ``ASTContext::getRawCommentForAnyRedecl()`` where the function could
723 sometimes incorrectly return null even if a comment was present. (#GH108145)
724 - Clang now correctly parses the argument of the ``relates``, ``related``, ``relatesalso``,
725 and ``relatedalso`` comment commands.
727 Miscellaneous Bug Fixes
728 ^^^^^^^^^^^^^^^^^^^^^^^
730 Miscellaneous Clang Crashes Fixed
731 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
733 - Fixed a crash in C due to incorrect lookup that members in nested anonymous struct/union
734 can be found as ordinary identifiers in struct/union definition. (#GH31295)
736 - Fixed a crash caused by long chains of ``sizeof`` and other similar operators
737 that can be followed by a non-parenthesized expression. (#GH45061)
739 - Fixed an crash when compiling ``#pragma STDC FP_CONTRACT DEFAULT`` with
740 ``-ffp-contract=fast-honor-pragmas``. (#GH104830)
742 - Fixed a crash when function has more than 65536 parameters.
743 Now a diagnostic is emitted. (#GH35741)
745 - Fixed ``-ast-dump`` crashes on codes involving ``concept`` with ``-ast-dump-decl-types``. (#GH94928)
747 - Fixed internal assertion firing when a declaration in the implicit global
748 module is found through ADL. (GH#109879)
750 OpenACC Specific Changes
751 ------------------------
753 Target Specific Changes
754 -----------------------
756 - Clang now implements the Solaris-specific mangling of ``std::tm`` as
757 ``tm``, same for ``std::div_t``, ``std::ldiv_t``, and
758 ``std::lconv``, for Solaris ABI compatibility. (#GH33114)
763 - Initial support for gfx950
765 - Added headers ``gpuintrin.h`` and ``amdgpuintrin.h`` that contains common
766 definitions for GPU builtin functions. This header can be included for OpenMP,
767 CUDA, HIP, OpenCL, and C/C++.
772 - Added headers ``gpuintrin.h`` and ``nvptxintrin.h`` that contains common
773 definitions for GPU builtin functions. This header can be included for OpenMP,
774 CUDA, HIP, OpenCL, and C/C++.
779 - The MMX vector intrinsic functions from ``*mmintrin.h`` which
780 operate on `__m64` vectors, such as ``_mm_add_pi8``, have been
781 reimplemented to use the SSE2 instruction-set and XMM registers
782 unconditionally. These intrinsics are therefore *no longer
783 supported* if MMX is enabled without SSE2 -- either from targeting
784 CPUs from the Pentium-MMX through the Pentium 3, or explicitly via
785 passing arguments such as ``-mmmx -mno-sse2``. MMX assembly code
786 remains supported without requiring SSE2, including inside
789 - The compiler builtins such as ``__builtin_ia32_paddb`` which
790 formerly implemented the above MMX intrinsic functions have been
791 removed. Any uses of these removed functions should migrate to the
792 functions defined by the ``*mmintrin.h`` headers. A mapping can be
793 found in the file ``clang/www/builtins.py``.
795 - Support ISA of ``AVX10.2``.
796 * Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
797 ``*_(mask(z)))_minmax_s[s|d|h]``.
799 - Supported intrinsics for ``SM4 and AVX10.2``.
800 * Supported SM4 intrinsics of ``_mm512_sm4key4_epi32`` and
801 ``_mm512_sm4rnds4_epi32``.
803 - All intrinsics in adcintrin.h can now be used in constant expressions.
805 - All intrinsics in adxintrin.h can now be used in constant expressions.
807 - All intrinsics in lzcntintrin.h can now be used in constant expressions.
809 - All intrinsics in bmiintrin.h can now be used in constant expressions.
811 - All intrinsics in bmi2intrin.h can now be used in constant expressions.
813 - All intrinsics in tbmintrin.h can now be used in constant expressions.
815 - Supported intrinsics for ``MOVRS AND AVX10.2``.
816 * Supported intrinsics of ``_mm(256|512)_(mask(z))_loadrs_epi(8|16|32|64)``.
817 - Support ISA of ``AMX-FP8``.
818 - Support ISA of ``AMX-TRANSPOSE``.
819 - Support ISA of ``AMX-MOVRS``.
820 - Support ISA of ``AMX-AVX512``.
821 - Support ISA of ``AMX-TF32``.
822 - Support ISA of ``MOVRS``.
824 - Supported ``-march/tune=diamondrapids``
826 Arm and AArch64 Support
827 ^^^^^^^^^^^^^^^^^^^^^^^
829 - In the ARM Target, the frame pointer (FP) of a leaf function can be retained
830 by using the ``-fno-omit-frame-pointer`` option. If you want to eliminate the FP
831 in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding
832 the ``-momit-leaf-frame-pointer`` option.
840 - clang-cl now supports ``/std:c++23preview`` which enables C++23 features.
842 - Clang no longer allows references inside a union when emulating MSVC 1900+ even if `fms-extensions` is enabled.
843 Starting with VS2015, MSVC 1900, this Microsoft extension is no longer allowed and always results in an error.
844 Clang now follows the MSVC behavior in this scenario.
845 When `-fms-compatibility-version=18.00` or prior is set on the command line this Microsoft extension is still
846 allowed as VS2013 and prior allow it.
854 - The option ``-mcmodel=large`` for the large code model is supported.
855 - Bump RVV intrinsic to version 1.0, the spec: https://github.com/riscv-non-isa/rvv-intrinsic-doc/releases/tag/v1.0.0-rc4
857 CUDA/HIP Language Changes
858 ^^^^^^^^^^^^^^^^^^^^^^^^^
862 - Clang now supports CUDA SDK up to 12.6
863 - Added support for sm_100
864 - Added support for `__grid_constant__` attribute.
875 The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
876 and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
877 and [Non-trapping float-to-int Conversions] language features, which are
878 [widely implemented in engines].
880 [Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
881 [Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
882 [widely implemented in engines]: https://webassembly.org/features/
887 - Reject C/C++ compilation for avr1 devices which have no SRAM.
889 DWARF Support in Clang
890 ----------------------
892 Floating Point Support in Clang
893 -------------------------------
895 - Add ``__builtin_elementwise_atan2`` builtin for floating point types only.
897 Fixed Point Support in Clang
898 ----------------------------
903 - Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
904 inline namespaces with an enclosing namespace of the same name.
906 - Fixed an ordering issue with the `hasOperands` matcher occurring when setting a
907 binding in the first matcher and using it in the second matcher.
909 - Fixed a crash when traverse lambda expr with invalid captures. (#GH106444)
911 - Fixed ``isInstantiated`` and ``isInTemplateInstantiation`` to also match for variable templates. (#GH110666)
913 - Ensure ``hasName`` matches template specializations across inline namespaces,
914 making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent.
919 - Adds ``BreakBinaryOperations`` option.
920 - Adds ``TemplateNames`` option.
921 - Adds ``AlignFunctionDeclarations`` option to ``AlignConsecutiveDeclarations``.
922 - Adds ``IndentOnly`` suboption to ``ReflowComments`` to fix the indentation of
923 multi-line comments without touching their contents, renames ``false`` to
924 ``Never``, and ``true`` to ``Always``.
925 - Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
926 - Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
930 - Add ``clang_isBeforeInTranslationUnit``. Given two source locations, it determines
931 whether the first one comes strictly before the second in the source code.
939 - Now CSA models `__builtin_*_overflow` functions. (#GH102602)
941 - MallocChecker now checks for ``ownership_returns(class, idx)`` and ``ownership_takes(class, idx)``
942 attributes with class names different from "malloc". Clang static analyzer now reports an error
943 if class of allocation and deallocation function mismatches.
944 `Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#unix-mismatcheddeallocator-c-c>`__.
946 - Function effects, e.g. the ``nonblocking`` and ``nonallocating`` "performance constraint"
947 attributes, are now verified. For example, for functions declared with the ``nonblocking``
948 attribute, the compiler can generate warnings about the use of any language features, or calls to
949 other functions, which may block.
951 - Introduced ``-warning-suppression-mappings`` flag to control diagnostic
952 suppressions per file. See `documentation <https://clang.llvm.org/docs/WarningSuppressionMappings.html>_` for details.
960 - Improved the handling of the ``ownership_returns`` attribute. Now, Clang reports an
961 error if the attribute is attached to a function that returns a non-pointer value.
967 - The checker ``alpha.security.MallocOverflow`` was deleted because it was
968 badly implemented and its agressive logic produced too many false positives.
969 To detect too large arguments passed to malloc, consider using the checker
970 ``alpha.taint.TaintedAlloc``.
972 - The checkers ``alpha.nondeterministic.PointerSorting`` and
973 ``alpha.nondeterministic.PointerIteration`` were moved to a new bugprone
974 checker named ``bugprone-nondeterministic-pointer-iteration-order``. The
975 original checkers were implemented only using AST matching and make more
976 sense as a single clang-tidy check.
978 .. _release-notes-sanitizers:
982 - Introduced Realtime Sanitizer, activated by using the -fsanitize=realtime
983 flag. This sanitizer detects unsafe system library calls, such as memory
984 allocations and mutex locks. If any such function is called during invocation
985 of a function marked with the ``[[clang::nonblocking]]`` attribute, an error
986 is printed to the console and the process exits non-zero.
988 - Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
989 used to disable specific overflow-dependent code patterns. The supported
990 patterns are: ``add-signed-overflow-test``, ``add-unsigned-overflow-test``,
991 ``negated-unsigned-const``, and ``unsigned-post-decr-while``. The sanitizer
992 instrumentation can be toggled off for all available patterns by specifying
993 ``all``. Conversely, you may disable all exclusions with ``none`` which is
998 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-unsigned-overflow-test``
999 int common_overflow_check_pattern(unsigned base, unsigned offset) {
1000 if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
1003 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-signed-overflow-test``
1004 int common_overflow_check_pattern_signed(signed int base, signed int offset) {
1005 if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
1008 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const``
1009 void negation_overflow() {
1010 unsigned long foo = -1UL; // No longer causes a negation overflow warning
1011 unsigned long bar = -2UL; // and so on...
1014 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=unsigned-post-decr-while``
1015 void while_post_decrement() {
1016 unsigned char count = 16;
1017 while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
1020 Many existing projects have a large amount of these code patterns present.
1021 This new flag should allow those projects to enable integer sanitizers with
1024 - ``-fsanitize=signed-integer-overflow``, ``-fsanitize=unsigned-integer-overflow``,
1025 ``-fsanitize=implicit-signed-integer-truncation``, ``-fsanitize=implicit-unsigned-integer-truncation``,
1026 ``-fsanitize=enum`` now properly support the
1027 "type" prefix within `Sanitizer Special Case Lists (SSCL)
1028 <https://clang.llvm.org/docs/SanitizerSpecialCaseList.html>`_. See that link
1031 Python Binding Changes
1032 ----------------------
1033 - Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.
1037 - Added support for 'omp assume' directive.
1038 - Added support for 'omp scope' directive.
1039 - Added support for allocator-modifier in 'allocate' clause.
1043 - Improve the handling of mapping array-section for struct containing nested structs with user defined mappers
1045 - `num_teams` and `thead_limit` now accept multiple expressions when it is used
1046 along in ``target teams ompx_bare`` construct. This allows the target region
1047 to be launched with multi-dim grid on GPUs.
1049 Additional Information
1050 ======================
1052 A wide variety of additional information is available on the `Clang web
1053 page <https://clang.llvm.org/>`_. The web page contains versions of the
1054 API documentation which are up-to-date with the Git version of
1055 the source code. You can access versions of these documents specific to
1056 this release by going into the "``clang/docs/``" directory in the Clang
1059 If you have any questions or comments about Clang, please feel free to
1060 contact us on the `Discourse forums (Clang Frontend category)
1061 <https://discourse.llvm.org/c/clang/6>`_.