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 ABI Changes in This Version
152 ---------------------------
154 - 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.
155 - 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)
156 - Mangle member-like friend function templates as members of the enclosing class. (#GH110247, #GH110503)
158 AST Dumping Potentially Breaking Changes
159 ----------------------------------------
161 Clang Frontend Potentially Breaking Changes
162 -------------------------------------------
164 Clang Python Bindings Potentially Breaking Changes
165 --------------------------------------------------
166 - Parts of the interface returning string results will now return
167 the empty string ``""`` when no result is available, instead of ``None``.
168 - Calling a property on the ``CompletionChunk`` or ``CompletionString`` class
169 statically now leads to an error, instead of returning a ``CachedProperty`` object
170 that is used internally. Properties are only available on instances.
171 - For a single-line ``SourceRange`` and a ``SourceLocation`` in the same line,
172 but after the end of the ``SourceRange``, ``SourceRange.__contains__``
173 used to incorrectly return ``True``. (#GH22617), (#GH52827)
175 What's New in Clang |release|?
176 ==============================
177 Some of the major new features and improvements to Clang are listed
178 here. Generic improvements to Clang as a whole or to its underlying
179 infrastructure are described first, followed by language-specific
180 sections with improvements to Clang's support for those languages.
184 - Allow single element access of GCC vector/ext_vector_type object to be
185 constant expression. Supports the `V.xyzw` syntax and other tidbits
186 as seen in OpenCL. Selecting multiple elements is left as a future work.
187 - Implement `CWG1815 <https://wg21.link/CWG1815>`_. Support lifetime extension
188 of temporary created by aggregate initialization using a default member
191 - Accept C++26 user-defined ``static_assert`` messages in C++11 as an extension.
193 - Add ``__builtin_elementwise_popcount`` builtin for integer types only.
195 - Add ``__builtin_elementwise_fmod`` builtin for floating point types only.
197 - Add ``__builtin_elementwise_minimum`` and ``__builtin_elementwise_maximum``
198 builtin for floating point types only.
200 - The builtin type alias ``__builtin_common_type`` has been added to improve the
201 performance of ``std::common_type``.
203 C++2c Feature Support
204 ^^^^^^^^^^^^^^^^^^^^^
206 - Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports
207 `P2647R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_
209 - Add ``__builtin_is_virtual_base_of`` intrinsic, which supports
210 `P2985R0 A type trait for detecting virtual base classes <https://wg21.link/p2985r0>`_
212 - Implemented `P2893R3 Variadic Friends <https://wg21.link/P2893>`_
214 - Implemented `P2747R2 constexpr placement new <https://wg21.link/P2747R2>`_.
216 - Added the ``__builtin_is_within_lifetime`` builtin, which supports
217 `P2641R4 Checking if a union alternative is active <https://wg21.link/p2641r4>`_
219 C++23 Feature Support
220 ^^^^^^^^^^^^^^^^^^^^^
221 - Removed the restriction to literal types in constexpr functions in C++23 mode.
223 - Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
224 supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
226 C++20 Feature Support
227 ^^^^^^^^^^^^^^^^^^^^^
230 Resolutions to C++ Defect Reports
231 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
233 - Allow calling initializer list constructors from initializer lists with
234 a single element of the same type instead of always copying.
235 (`CWG2137: List-initialization from object of same type <https://cplusplus.github.io/CWG/issues/2137.html>`)
237 - Speculative resolution for CWG2311 implemented so that the implementation of CWG2137 doesn't remove
238 previous cases where guaranteed copy elision was done. Given a prvalue ``e`` of class type
239 ``T``, ``T{e}`` will try to resolve an initializer list constructor and will use it if successful.
240 Otherwise, if there is no initializer list constructor, the copy will be elided as if it was ``T(e)``.
241 (`CWG2311: Missed case for guaranteed copy elision <https://cplusplus.github.io/CWG/issues/2311.html>`)
243 - Casts from a bit-field to an integral type is now not considered narrowing if the
244 width of the bit-field means that all potential values are in the range
245 of the target type, even if the type of the bit-field is larger.
246 (`CWG2627: Bit-fields and narrowing conversions <https://cplusplus.github.io/CWG/issues/2627.html>`_)
248 - ``nullptr`` is now promoted to ``void*`` when passed to a C-style variadic function.
249 (`CWG722: Can nullptr be passed to an ellipsis? <https://cplusplus.github.io/CWG/issues/722.html>`_)
251 - Allow ``void{}`` as a prvalue of type ``void``.
252 (`CWG2351: void{} <https://cplusplus.github.io/CWG/issues/2351.html>`_).
254 - Clang now has improved resolution to CWG2398, allowing class templates to have
255 default arguments deduced when partial ordering.
257 - Clang now allows comparing unequal object pointers that have been cast to ``void *``
258 in constant expressions. These comparisons always worked in non-constant expressions.
259 (`CWG2749: Treatment of "pointer to void" for relational comparisons <https://cplusplus.github.io/CWG/issues/2749.html>`_).
261 - Reject explicit object parameters with type ``void`` (``this void``).
262 (`CWG2915: Explicit object parameters of type void <https://cplusplus.github.io/CWG/issues/2915.html>`_).
264 - Clang now allows trailing requires clause on explicit deduction guides.
265 (`CWG2707: Deduction guides cannot have a trailing requires-clause <https://cplusplus.github.io/CWG/issues/2707.html>`_).
267 - Clang now diagnoses a space in the first production of a ``literal-operator-id``
269 (`CWG2521: User-defined literals and reserved identifiers <https://cplusplus.github.io/CWG/issues/2521.html>`_).
274 - Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
279 - Updated conformance for `N3298 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3298.htm>`_
280 which adds the ``i`` and ``j`` suffixes for the creation of a ``_Complex``
281 constant value. Clang has always supported these suffixes as a GNU extension,
282 so ``-Wgnu-imaginary-constant`` no longer has effect in C modes, as this is
283 now a C2y extension in C. ``-Wgnu-imaginary-constant`` still applies in C++
286 - Clang updated conformance for `N3370 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3370.htm>`_
287 case range expressions. This feature was previously supported by Clang as a
288 GNU extension, so ``-Wgnu-case-range`` no longer has effect in C modes, as
289 this is now a C2y extension in C. ``-Wgnu-case-range`` still applies in C++
292 - Clang implemented support for `N3344 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3344.pdf>`_
293 which disallows a ``void`` parameter from having a qualifier or storage class
294 specifier. Note that ``register void`` was previously accepted in all C
295 language modes but is now rejected (all of the other qualifiers and storage
296 class specifiers were previously rejected).
298 - Updated conformance for `N3364 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3364.pdf>`_
299 on floating-point translation-time initialization with signaling NaN. This
300 paper adopts Clang's existing practice, so there were no changes to compiler
303 - Implemented support for `N3341 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3341.pdf>`_
304 which makes empty structure and union objects implementation-defined in C.
305 ``-Wgnu-empty-struct`` will be emitted in C23 and earlier modes because the
306 behavior is a conforming GNU extension in those modes, but will no longer
307 have an effect in C2y mode.
309 - Updated conformance for `N3342 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3342.pdf>`_
310 which made qualified function types implementation-defined rather than
311 undefined. Clang has always accepted ``const`` and ``volatile`` qualified
312 function types by ignoring the qualifiers.
314 - Updated conformance for `N3346 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3346.pdf>`_
315 which changes some undefined behavior around initialization to instead be
316 constraint violations. This paper adopts Clang's existing practice, so there
317 were no changes to compiler behavior.
322 - Clang now supports `N3029 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3029.htm>`_ Improved Normal Enumerations.
323 - 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.
325 Non-comprehensive list of changes in this release
326 -------------------------------------------------
328 - The floating point comparison builtins (``__builtin_isgreater``,
329 ``__builtin_isgreaterequal``, ``__builtin_isless``, etc.) and
330 ``__builtin_signbit`` can now be used in constant expressions.
331 - Plugins can now define custom attributes that apply to statements
332 as well as declarations.
333 - ``__builtin_abs`` function can now be used in constant expressions.
335 - The new builtin ``__builtin_counted_by_ref`` was added. In contexts where the
336 programmer needs access to the ``counted_by`` attribute's field, but it's not
337 available --- e.g. in macros. For instace, it can be used to automatically
338 set the counter during allocation in the Linux kernel:
342 /* A simplified version of Linux allocation macros */
343 #define alloc(PTR, FAM, COUNT) ({ \
344 sizeof_t __ignored_assignment; \
346 size_t __size = sizeof(*P) + sizeof(*P->FAM) * COUNT; \
347 __p = malloc(__size); \
349 __builtin_counted_by_ref(__p->FAM), \
350 void *: &__ignored_assignment, \
351 default: __builtin_counted_by_ref(__p->FAM)) = COUNT; \
355 The flexible array member (FAM) can now be accessed immediately without causing
356 issues with the sanitizer because the counter is automatically set.
358 - ``__builtin_reduce_add`` function can now be used in constant expressions.
359 - ``__builtin_reduce_mul`` function can now be used in constant expressions.
360 - ``__builtin_reduce_and`` function can now be used in constant expressions.
365 - The ``-fc++-static-destructors={all,thread-local,none}`` flag was
366 added to control which C++ variables have static destructors
367 registered: all (the default) does so for all variables, thread-local
368 only for thread-local variables, and none (which corresponds to the
369 existing ``-fno-c++-static-destructors`` flag) skips all static
370 destructors registration.
372 Deprecated Compiler Flags
373 -------------------------
375 - ``-fheinous-gnu-extensions`` is deprecated; it is now equivalent to
376 specifying ``-Wno-error=invalid-gnu-asm-cast`` and may be removed in the
379 Modified Compiler Flags
380 -----------------------
382 - The ``-ffp-model`` option has been updated to enable a more limited set of
383 optimizations when the ``fast`` argument is used and to accept a new argument,
384 ``aggressive``. The behavior of ``-ffp-model=aggressive`` is equivalent
385 to the previous behavior of ``-ffp-model=fast``. The updated
386 ``-ffp-model=fast`` behavior no longer assumes finite math only and uses
387 the ``promoted`` algorithm for complex division when possible rather than the
388 less basic (limited range) algorithm.
390 - The ``-fveclib`` option has been updated to enable ``-fno-math-errno`` for
391 ``-fveclib=ArmPL`` and ``-fveclib=SLEEF``. This gives Clang more opportunities
392 to utilize these vector libraries. The behavior for all other vector function
393 libraries remains unchanged.
395 - The ``-Wnontrivial-memaccess`` warning has been updated to also warn about
396 passing non-trivially-copyable destrination parameter to ``memcpy``,
397 ``memset`` and similar functions for which it is a documented undefined
400 Removed Compiler Flags
401 -------------------------
403 - The compiler flag `-Wenum-constexpr-conversion` (and the `Wno-`, `Wno-error-`
404 derivatives) is now removed, since it's no longer possible to suppress the
405 diagnostic (see above). Users can expect an `unknown warning` diagnostic if
408 Attribute Changes in Clang
409 --------------------------
411 - The ``swift_attr`` can now be applied to types. To make it possible to use imported APIs
412 in Swift safely there has to be a way to annotate individual parameters and result types
413 with relevant attributes that indicate that e.g. a block is called on a particular actor
414 or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated parameter.
421 -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"))))(id)) handler;
424 - Clang now disallows more than one ``__attribute__((ownership_returns(class, idx)))`` with
425 different class names attached to one function.
427 - Introduced a new format attribute ``__attribute__((format(syslog, 1, 2)))`` from OpenBSD.
429 - The ``hybrid_patchable`` attribute is now supported on ARM64EC targets. It can be used to specify
430 that a function requires an additional x86-64 thunk, which may be patched at runtime.
432 - ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions
433 where they were previously silently ignored.
435 - Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of
436 ``std::span, std::string_view`` constructors, this enables Clang to capture
437 more cases where the returned reference outlives the object.
440 - Clang now correctly diagnoses the use of ``btf_type_tag`` in C++ and ignores
441 it; this attribute is a C-only attribute, and caused crashes with template
442 instantiation by accidentally allowing it in C++ in some circumstances.
445 - Introduced a new attribute ``[[clang::coro_await_elidable]]`` on coroutine return types
446 to express elideability at call sites where the coroutine is invoked under a safe elide context.
448 - Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on function parameters
449 to propagate safe elide context to arguments if such function is also under a safe elide context.
451 - The documentation of the ``[[clang::musttail]]`` attribute was updated to
452 note that the lifetimes of all local variables end before the call. This does
453 not change the behaviour of the compiler, as this was true for previous
456 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
457 ``[[gsl::Pointer]]`` to STL explicit template specialization decls. (#GH109442)
459 - Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be
460 used to specify when a reference to a function parameter is captured by another capturing entity ``X``.
462 Improvements to Clang's diagnostics
463 -----------------------------------
465 - Some template related diagnostics have been improved.
469 void foo() { template <typename> int i; } // error: templates can only be declared in namespace or class scope
472 template <typename> int i; // error: non-static data member 'i' cannot be declared as a template
475 - Clang now has improved diagnostics for functions with explicit 'this' parameters. Fixes #GH97878
477 - Clang now diagnoses dangling references to fields of temporary objects. Fixes #GH81589.
479 - Clang now diagnoses undefined behavior in constant expressions more consistently. This includes invalid shifts, and signed overflow in arithmetic.
481 - -Wdangling-assignment-gsl is enabled by default.
482 - Clang now always preserves the template arguments as written used
483 to specialize template type aliases.
485 - Clang now diagnoses the use of ``main`` in an ``extern`` context as invalid according to [basic.start.main] p3. Fixes #GH101512.
487 - Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.
489 - Don't emit duplicated dangling diagnostics. (#GH93386).
491 - Improved diagnostic when trying to befriend a concept. (#GH45182).
493 - Added the ``-Winvalid-gnu-asm-cast`` diagnostic group to control warnings
494 about use of "noop" casts for lvalues (a GNU extension). This diagnostic is
495 a warning which defaults to being an error, is enabled by default, and is
496 also controlled by the now-deprecated ``-fheinous-gnu-extensions`` flag.
498 - Added the ``-Wdecls-in-multiple-modules`` option to assist users to identify
499 multiple declarations in different modules, which is the major reason of the slow
500 compilation speed with modules. This warning is disabled by default and it needs
501 to be explicitly enabled or by ``-Weverything``.
503 - Improved diagnostic when trying to overload a function in an ``extern "C"`` context. (#GH80235)
505 - Clang now respects lifetimebound attribute for the assignment operator parameter. (#GH106372).
507 - The lifetimebound and GSL analysis in clang are coherent, allowing clang to
508 detect more use-after-free bugs. (#GH100549).
510 - Clang now diagnoses dangling cases where a gsl-pointer is constructed from a gsl-owner object inside a container (#GH100384).
512 - Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
514 - Clang now diagnose when importing module implementation partition units in module interface units.
516 - Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::lifetimebound]]` are used together (#GH108272).
518 - The ``-Wreturn-stack-address`` warning now also warns about addresses of
519 local variables passed to function calls using the ``[[clang::musttail]]``
522 - Clang now diagnoses cases where a dangling ``GSLOwner<GSLPointer>`` object is constructed, e.g. ``std::vector<string_view> v = {std::string()};`` (#GH100526).
524 - Clang now diagnoses when a ``requires`` expression has a local parameter of void type, aligning with the function parameter (#GH109831).
526 - Clang now emits a diagnostic note at the class declaration when the method definition does not match any declaration (#GH110638).
528 - Clang now omits warnings for extra parentheses in fold expressions with single expansion (#GH101863).
530 - The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``,
531 instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being
532 suboptimal in some way the error fails to mention (#GH111550).
534 - Clang now emits a ``-Wdepredcated-literal-operator`` diagnostic, even if the
535 name was a reserved name, which we improperly allowed to suppress the
538 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073).
540 - Improved diagnostic message for ``__builtin_bit_cast`` size mismatch (#GH115870).
542 - Clang now omits shadow warnings for enum constants in separate class scopes (#GH62588).
544 - When diagnosing an unused return value of a type declared ``[[nodiscard]]``, the type
545 itself is now included in the diagnostic.
547 - Clang will now prefer the ``[[nodiscard]]`` declaration on function declarations over ``[[nodiscard]]``
548 declaration on the return type of a function. Previously, when both have a ``[[nodiscard]]`` declaration attached,
549 the one on the return type would be preferred. This may affect the generated warning message:
553 struct [[nodiscard("Reason 1")]] S {};
554 [[nodiscard("Reason 2")]] S getS();
557 getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
560 - Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
562 - Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485).
564 Improvements to Clang's time-trace
565 ----------------------------------
567 Improvements to Coverage Mapping
568 --------------------------------
570 Bug Fixes in This Version
571 -------------------------
573 - Fixed the definition of ``ATOMIC_FLAG_INIT`` in ``<stdatomic.h>`` so it can
575 - Fixed a failed assertion when checking required literal types in C context. (#GH101304).
576 - Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685.
577 - Fixed a crash when diagnosing format strings and encountering an empty
578 delimited escape sequence (e.g., ``"\o{}"``). #GH102218
579 - Fixed a crash using ``__array_rank`` on 64-bit targets. (#GH113044).
580 - The warning emitted for an unsupported register variable type now points to
581 the unsupported type instead of the ``register`` keyword (#GH109776).
582 - Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
583 - Fixed a crash when GNU statement expression contains invalid statement (#GH113468).
584 - Fixed a failed assertion when using ``__attribute__((noderef))`` on an
585 ``_Atomic``-qualified type (#GH116124).
587 Bug Fixes to Compiler Builtins
588 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
590 - Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330)
592 - Clang now allows pointee types of atomic builtin arguments to be complete template types
593 that was not instantiated elsewhere.
595 - ``__noop`` can now be used in a constant expression. (#GH102064)
597 - Fix ``__has_builtin`` incorrectly returning ``false`` for some C++ type traits. (#GH111477)
599 Bug Fixes to Attribute Support
600 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
602 Bug Fixes to C++ Support
603 ^^^^^^^^^^^^^^^^^^^^^^^^
605 - Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646)
606 - Fixed incorrect pack expansion of init-capture references in requires expresssions.
607 - Fixed a failed assertion when checking invalid delete operator declaration. (#GH96191)
608 - Fix a crash when checking destructor reference with an invalid initializer. (#GH97230)
609 - Clang now correctly parses potentially declarative nested-name-specifiers in pointer-to-member declarators.
610 - Fix a crash when checking the initialzier of an object that was initialized
611 with a string literal. (#GH82167)
612 - Fix a crash when matching template template parameters with templates which have
613 parameters of different class type. (#GH101394)
614 - Clang now correctly recognizes the correct context for parameter
615 substitutions in concepts, so it doesn't incorrectly complain of missing
616 module imports in those situations. (#GH60336)
617 - Fix init-capture packs having a size of one before being instantiated. (#GH63677)
618 - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
620 - Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
621 - Fixed an assertion failure when selecting a function from an overload set that includes a
622 specialization of a conversion function template.
623 - Correctly diagnose attempts to use a concept name in its own definition;
624 A concept name is introduced to its scope sooner to match the C++ standard. (#GH55875)
625 - Properly reject defaulted relational operators with invalid types for explicit object parameters,
626 e.g., ``bool operator==(this int, const Foo&)`` (#GH100329), and rvalue reference parameters.
627 - Properly reject defaulted copy/move assignment operators that have a non-reference explicit object parameter.
628 - Clang now properly handles the order of attributes in `extern` blocks. (#GH101990).
629 - Fixed an assertion failure by preventing null explicit object arguments from being deduced. (#GH102025).
630 - Correctly check constraints of explicit instantiations of member functions. (#GH46029)
631 - When performing partial ordering of function templates, clang now checks that
632 the deduction was consistent. Fixes (#GH18291).
633 - Fixed an assertion failure about a constraint of a friend function template references to a value with greater
634 template depth than the friend function template. (#GH98258)
635 - Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
636 of the current instantiation in all cases.
637 - Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900)
638 - Correctly handle subexpressions of an immediate invocation in the presence of implicit casts. (#GH105558)
639 - Clang now correctly handles direct-list-initialization of a structured bindings from an array. (#GH31813)
640 - Mangle placeholders for deduced types as a template-prefix, such that mangling
641 of template template parameters uses the correct production. (#GH106182)
642 - Fixed an assertion failure when converting vectors to int/float with invalid expressions. (#GH105486)
643 - Template parameter names are considered in the name lookup of out-of-line class template
644 specialization right before its declaration context. (#GH64082)
645 - Fixed a constraint comparison bug for friend declarations. (#GH78101)
646 - Fix handling of ``_`` as the name of a lambda's init capture variable. (#GH107024)
647 - Fix an issue with dependent source location expressions (#GH106428), (#GH81155), (#GH80210), (#GH85373)
648 - Fixed a bug in the substitution of empty pack indexing types. (#GH105903)
649 - Clang no longer tries to capture non-odr used default arguments of template parameters of generic lambdas (#GH107048)
650 - Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588)
651 - Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134)
652 - A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361), (#GH112352)
653 - Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)
654 - Fixed a crash when clang tries to subtitute parameter pack while retaining the parameter
655 pack. (#GH63819), (#GH107560)
656 - Fix a crash when a static assert declaration has an invalid close location. (#GH108687)
657 - Avoided a redundant friend declaration instantiation under a certain ``consteval`` context. (#GH107175)
658 - Fixed an assertion failure in debug mode, and potential crashes in release mode, when
659 diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
660 - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
661 - Fixed a crash when mixture of designated and non-designated initializers in union. (#GH113855)
662 - Fixed an issue deducing non-type template arguments of reference type. (#GH73460)
663 - Fixed an issue in constraint evaluation, where type constraints on the lambda expression
664 containing outer unexpanded parameters were not correctly expanded. (#GH101754)
665 - Fixes crashes with function template member specializations, and increases
666 conformance of explicit instantiation behaviour with MSVC. (#GH111266)
667 - Fixed a bug in constraint expression comparison where the ``sizeof...`` expression was not handled properly
668 in certain friend declarations. (#GH93099)
669 - Clang now instantiates the correct lambda call operator when a lambda's class type is
670 merged across modules. (#GH110401)
671 - Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
672 - Fixed an assertion failure when invoking recovery call expressions with explicit attributes
673 and undeclared templates. (#GH107047), (#GH49093)
674 - Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded
675 parameter pack. (#GH109148)
676 - Fixed overload handling for object parameters with top-level cv-qualifiers in explicit member functions (#GH100394)
677 - Fixed a bug in lambda captures where ``constexpr`` class-type objects were not properly considered ODR-used in
678 certain situations. (#GH47400), (#GH90896)
679 - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441)
680 - During the lookup for a base class name, non-type names are ignored. (#GH16855)
681 - Fix a crash when recovering an invalid expression involving an explicit object member conversion operator. (#GH112559)
682 - Clang incorrectly considered a class with an anonymous union member to not be
683 const-default-constructible even if a union member has a default member initializer.
685 - Fixed an assertion failure when evaluating an invalid expression in an array initializer. (#GH112140)
686 - Fixed an assertion failure in range calculations for conditional throw expressions. (#GH111854)
687 - Clang now correctly ignores previous partial specializations of member templates explicitly specialized for
688 an implicitly instantiated class template specialization. (#GH51051)
689 - Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208)
690 - Name independent data members were not correctly initialized from default member initializers. (#GH114069)
691 - Fixed expression transformation for ``[[assume(...)]]``, allowing using pack indexing expressions within the
692 assumption if they also occur inside of a dependent lambda. (#GH114787)
693 - Clang now uses valid deduced type locations when diagnosing functions with trailing return type
694 missing placeholder return type. (#GH78694)
696 Bug Fixes to AST Handling
697 ^^^^^^^^^^^^^^^^^^^^^^^^^
699 - Fixed a crash that occurred when dividing by zero in complex integer division. (#GH55390).
700 - Fixed a bug in ``ASTContext::getRawCommentForAnyRedecl()`` where the function could
701 sometimes incorrectly return null even if a comment was present. (#GH108145)
702 - Clang now correctly parses the argument of the ``relates``, ``related``, ``relatesalso``,
703 and ``relatedalso`` comment commands.
705 Miscellaneous Bug Fixes
706 ^^^^^^^^^^^^^^^^^^^^^^^
708 Miscellaneous Clang Crashes Fixed
709 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
711 - Fixed a crash in C due to incorrect lookup that members in nested anonymous struct/union
712 can be found as ordinary identifiers in struct/union definition. (#GH31295)
714 - Fixed a crash caused by long chains of ``sizeof`` and other similar operators
715 that can be followed by a non-parenthesized expression. (#GH45061)
717 - Fixed an crash when compiling ``#pragma STDC FP_CONTRACT DEFAULT`` with
718 ``-ffp-contract=fast-honor-pragmas``. (#GH104830)
720 - Fixed a crash when function has more than 65536 parameters.
721 Now a diagnostic is emitted. (#GH35741)
723 - Fixed ``-ast-dump`` crashes on codes involving ``concept`` with ``-ast-dump-decl-types``. (#GH94928)
725 - Fixed internal assertion firing when a declaration in the implicit global
726 module is found through ADL. (GH#109879)
728 OpenACC Specific Changes
729 ------------------------
731 Target Specific Changes
732 -----------------------
734 - Clang now implements the Solaris-specific mangling of ``std::tm`` as
735 ``tm``, same for ``std::div_t``, ``std::ldiv_t``, and
736 ``std::lconv``, for Solaris ABI compatibility. (#GH33114)
741 - Initial support for gfx950
743 - Added headers ``gpuintrin.h`` and ``amdgpuintrin.h`` that contains common
744 definitions for GPU builtin functions. This header can be included for OpenMP,
745 CUDA, HIP, OpenCL, and C/C++.
750 - Added headers ``gpuintrin.h`` and ``nvptxintrin.h`` that contains common
751 definitions for GPU builtin functions. This header can be included for OpenMP,
752 CUDA, HIP, OpenCL, and C/C++.
757 - The MMX vector intrinsic functions from ``*mmintrin.h`` which
758 operate on `__m64` vectors, such as ``_mm_add_pi8``, have been
759 reimplemented to use the SSE2 instruction-set and XMM registers
760 unconditionally. These intrinsics are therefore *no longer
761 supported* if MMX is enabled without SSE2 -- either from targeting
762 CPUs from the Pentium-MMX through the Pentium 3, or explicitly via
763 passing arguments such as ``-mmmx -mno-sse2``. MMX assembly code
764 remains supported without requiring SSE2, including inside
767 - The compiler builtins such as ``__builtin_ia32_paddb`` which
768 formerly implemented the above MMX intrinsic functions have been
769 removed. Any uses of these removed functions should migrate to the
770 functions defined by the ``*mmintrin.h`` headers. A mapping can be
771 found in the file ``clang/www/builtins.py``.
773 - Support ISA of ``AVX10.2``.
774 * Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
775 ``*_(mask(z)))_minmax_s[s|d|h]``.
777 - Supported intrinsics for ``SM4 and AVX10.2``.
778 * Supported SM4 intrinsics of ``_mm512_sm4key4_epi32`` and
779 ``_mm512_sm4rnds4_epi32``.
781 - All intrinsics in adcintrin.h can now be used in constant expressions.
783 - All intrinsics in adxintrin.h can now be used in constant expressions.
785 - All intrinsics in lzcntintrin.h can now be used in constant expressions.
787 - All intrinsics in bmiintrin.h can now be used in constant expressions.
789 - All intrinsics in bmi2intrin.h can now be used in constant expressions.
791 - All intrinsics in tbmintrin.h can now be used in constant expressions.
793 - Supported intrinsics for ``MOVRS AND AVX10.2``.
794 * Supported intrinsics of ``_mm(256|512)_(mask(z))_loadrs_epi(8|16|32|64)``.
795 - Support ISA of ``AMX-FP8``.
796 - Support ISA of ``AMX-TRANSPOSE``.
797 - Support ISA of ``AMX-MOVRS``.
798 - Support ISA of ``AMX-AVX512``.
799 - Support ISA of ``AMX-TF32``.
800 - Support ISA of ``MOVRS``.
802 - Supported ``-march/tune=diamondrapids``
804 Arm and AArch64 Support
805 ^^^^^^^^^^^^^^^^^^^^^^^
807 - In the ARM Target, the frame pointer (FP) of a leaf function can be retained
808 by using the ``-fno-omit-frame-pointer`` option. If you want to eliminate the FP
809 in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding
810 the ``-momit-leaf-frame-pointer`` option.
818 - clang-cl now supports ``/std:c++23preview`` which enables C++23 features.
820 - Clang no longer allows references inside a union when emulating MSVC 1900+ even if `fms-extensions` is enabled.
821 Starting with VS2015, MSVC 1900, this Microsoft extension is no longer allowed and always results in an error.
822 Clang now follows the MSVC behavior in this scenario.
823 When `-fms-compatibility-version=18.00` or prior is set on the command line this Microsoft extension is still
824 allowed as VS2013 and prior allow it.
832 - The option ``-mcmodel=large`` for the large code model is supported.
834 CUDA/HIP Language Changes
835 ^^^^^^^^^^^^^^^^^^^^^^^^^
839 - Clang now supports CUDA SDK up to 12.6
840 - Added support for sm_100
841 - Added support for `__grid_constant__` attribute.
852 The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
853 and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
854 and [Non-trapping float-to-int Conversions] language features, which are
855 [widely implemented in engines].
857 [Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
858 [Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
859 [widely implemented in engines]: https://webassembly.org/features/
864 - Reject C/C++ compilation for avr1 devices which have no SRAM.
866 DWARF Support in Clang
867 ----------------------
869 Floating Point Support in Clang
870 -------------------------------
872 - Add ``__builtin_elementwise_atan2`` builtin for floating point types only.
874 Fixed Point Support in Clang
875 ----------------------------
880 - Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
881 inline namespaces with an enclosing namespace of the same name.
883 - Fixed an ordering issue with the `hasOperands` matcher occurring when setting a
884 binding in the first matcher and using it in the second matcher.
886 - Fixed a crash when traverse lambda expr with invalid captures. (#GH106444)
888 - Fixed ``isInstantiated`` and ``isInTemplateInstantiation`` to also match for variable templates. (#GH110666)
890 - Ensure ``hasName`` matches template specializations across inline namespaces,
891 making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent.
896 - Adds ``BreakBinaryOperations`` option.
897 - Adds ``TemplateNames`` option.
898 - Adds ``AlignFunctionDeclarations`` option to ``AlignConsecutiveDeclarations``.
899 - Adds ``IndentOnly`` suboption to ``ReflowComments`` to fix the indentation of
900 multi-line comments without touching their contents, renames ``false`` to
901 ``Never``, and ``true`` to ``Always``.
902 - Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
903 - Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
907 - Add ``clang_isBeforeInTranslationUnit``. Given two source locations, it determines
908 whether the first one comes strictly before the second in the source code.
916 - Now CSA models `__builtin_*_overflow` functions. (#GH102602)
918 - MallocChecker now checks for ``ownership_returns(class, idx)`` and ``ownership_takes(class, idx)``
919 attributes with class names different from "malloc". Clang static analyzer now reports an error
920 if class of allocation and deallocation function mismatches.
921 `Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#unix-mismatcheddeallocator-c-c>`__.
923 - Function effects, e.g. the ``nonblocking`` and ``nonallocating`` "performance constraint"
924 attributes, are now verified. For example, for functions declared with the ``nonblocking``
925 attribute, the compiler can generate warnings about the use of any language features, or calls to
926 other functions, which may block.
928 - Introduced ``-warning-suppression-mappings`` flag to control diagnostic
929 suppressions per file. See `documentation <https://clang.llvm.org/docs/WarningSuppressionMappings.html>_` for details.
937 - Improved the handling of the ``ownership_returns`` attribute. Now, Clang reports an
938 error if the attribute is attached to a function that returns a non-pointer value.
944 - The checker ``alpha.security.MallocOverflow`` was deleted because it was
945 badly implemented and its agressive logic produced too many false positives.
946 To detect too large arguments passed to malloc, consider using the checker
947 ``alpha.taint.TaintedAlloc``.
949 - The checkers ``alpha.nondeterministic.PointerSorting`` and
950 ``alpha.nondeterministic.PointerIteration`` were moved to a new bugprone
951 checker named ``bugprone-nondeterministic-pointer-iteration-order``. The
952 original checkers were implemented only using AST matching and make more
953 sense as a single clang-tidy check.
955 .. _release-notes-sanitizers:
959 - Introduced Realtime Sanitizer, activated by using the -fsanitize=realtime
960 flag. This sanitizer detects unsafe system library calls, such as memory
961 allocations and mutex locks. If any such function is called during invocation
962 of a function marked with the ``[[clang::nonblocking]]`` attribute, an error
963 is printed to the console and the process exits non-zero.
965 - Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
966 used to disable specific overflow-dependent code patterns. The supported
967 patterns are: ``add-signed-overflow-test``, ``add-unsigned-overflow-test``,
968 ``negated-unsigned-const``, and ``unsigned-post-decr-while``. The sanitizer
969 instrumentation can be toggled off for all available patterns by specifying
970 ``all``. Conversely, you may disable all exclusions with ``none`` which is
975 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-unsigned-overflow-test``
976 int common_overflow_check_pattern(unsigned base, unsigned offset) {
977 if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
980 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-signed-overflow-test``
981 int common_overflow_check_pattern_signed(signed int base, signed int offset) {
982 if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
985 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const``
986 void negation_overflow() {
987 unsigned long foo = -1UL; // No longer causes a negation overflow warning
988 unsigned long bar = -2UL; // and so on...
991 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=unsigned-post-decr-while``
992 void while_post_decrement() {
993 unsigned char count = 16;
994 while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
997 Many existing projects have a large amount of these code patterns present.
998 This new flag should allow those projects to enable integer sanitizers with
1001 - ``-fsanitize=signed-integer-overflow``, ``-fsanitize=unsigned-integer-overflow``,
1002 ``-fsanitize=implicit-signed-integer-truncation``, ``-fsanitize=implicit-unsigned-integer-truncation``,
1003 ``-fsanitize=enum`` now properly support the
1004 "type" prefix within `Sanitizer Special Case Lists (SSCL)
1005 <https://clang.llvm.org/docs/SanitizerSpecialCaseList.html>`_. See that link
1008 Python Binding Changes
1009 ----------------------
1010 - Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.
1014 - Added support for 'omp assume' directive.
1015 - Added support for 'omp scope' directive.
1016 - Added support for allocator-modifier in 'allocate' clause.
1020 - Improve the handling of mapping array-section for struct containing nested structs with user defined mappers
1022 - `num_teams` and `thead_limit` now accept multiple expressions when it is used
1023 along in ``target teams ompx_bare`` construct. This allows the target region
1024 to be launched with multi-dim grid on GPUs.
1026 Additional Information
1027 ======================
1029 A wide variety of additional information is available on the `Clang web
1030 page <https://clang.llvm.org/>`_. The web page contains versions of the
1031 API documentation which are up-to-date with the Git version of
1032 the source code. You can access versions of these documents specific to
1033 this release by going into the "``clang/docs/``" directory in the Clang
1036 If you have any questions or comments about Clang, please feel free to
1037 contact us on the `Discourse forums (Clang Frontend category)
1038 <https://discourse.llvm.org/c/clang/6>`_.