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.
364 - The ``-fc++-static-destructors={all,thread-local,none}`` flag was
365 added to control which C++ variables have static destructors
366 registered: all (the default) does so for all variables, thread-local
367 only for thread-local variables, and none (which corresponds to the
368 existing ``-fno-c++-static-destructors`` flag) skips all static
369 destructors registration.
371 Deprecated Compiler Flags
372 -------------------------
374 - ``-fheinous-gnu-extensions`` is deprecated; it is now equivalent to
375 specifying ``-Wno-error=invalid-gnu-asm-cast`` and may be removed in the
378 Modified Compiler Flags
379 -----------------------
381 - The ``-ffp-model`` option has been updated to enable a more limited set of
382 optimizations when the ``fast`` argument is used and to accept a new argument,
383 ``aggressive``. The behavior of ``-ffp-model=aggressive`` is equivalent
384 to the previous behavior of ``-ffp-model=fast``. The updated
385 ``-ffp-model=fast`` behavior no longer assumes finite math only and uses
386 the ``promoted`` algorithm for complex division when possible rather than the
387 less basic (limited range) algorithm.
389 - The ``-fveclib`` option has been updated to enable ``-fno-math-errno`` for
390 ``-fveclib=ArmPL`` and ``-fveclib=SLEEF``. This gives Clang more opportunities
391 to utilize these vector libraries. The behavior for all other vector function
392 libraries remains unchanged.
394 - The ``-Wnontrivial-memaccess`` warning has been updated to also warn about
395 passing non-trivially-copyable destrination parameter to ``memcpy``,
396 ``memset`` and similar functions for which it is a documented undefined
399 Removed Compiler Flags
400 -------------------------
402 - The compiler flag `-Wenum-constexpr-conversion` (and the `Wno-`, `Wno-error-`
403 derivatives) is now removed, since it's no longer possible to suppress the
404 diagnostic (see above). Users can expect an `unknown warning` diagnostic if
407 Attribute Changes in Clang
408 --------------------------
410 - The ``swift_attr`` can now be applied to types. To make it possible to use imported APIs
411 in Swift safely there has to be a way to annotate individual parameters and result types
412 with relevant attributes that indicate that e.g. a block is called on a particular actor
413 or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated parameter.
420 -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"))))(id)) handler;
423 - Clang now disallows more than one ``__attribute__((ownership_returns(class, idx)))`` with
424 different class names attached to one function.
426 - Introduced a new format attribute ``__attribute__((format(syslog, 1, 2)))`` from OpenBSD.
428 - The ``hybrid_patchable`` attribute is now supported on ARM64EC targets. It can be used to specify
429 that a function requires an additional x86-64 thunk, which may be patched at runtime.
431 - ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions
432 where they were previously silently ignored.
434 - Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of
435 ``std::span, std::string_view`` constructors, this enables Clang to capture
436 more cases where the returned reference outlives the object.
439 - Clang now correctly diagnoses the use of ``btf_type_tag`` in C++ and ignores
440 it; this attribute is a C-only attribute, and caused crashes with template
441 instantiation by accidentally allowing it in C++ in some circumstances.
444 - Introduced a new attribute ``[[clang::coro_await_elidable]]`` on coroutine return types
445 to express elideability at call sites where the coroutine is invoked under a safe elide context.
447 - Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on function parameters
448 to propagate safe elide context to arguments if such function is also under a safe elide context.
450 - The documentation of the ``[[clang::musttail]]`` attribute was updated to
451 note that the lifetimes of all local variables end before the call. This does
452 not change the behaviour of the compiler, as this was true for previous
455 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
456 ``[[gsl::Pointer]]`` to STL explicit template specialization decls. (#GH109442)
458 - Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be
459 used to specify when a reference to a function parameter is captured by another capturing entity ``X``.
461 Improvements to Clang's diagnostics
462 -----------------------------------
464 - Some template related diagnostics have been improved.
468 void foo() { template <typename> int i; } // error: templates can only be declared in namespace or class scope
471 template <typename> int i; // error: non-static data member 'i' cannot be declared as a template
474 - Clang now has improved diagnostics for functions with explicit 'this' parameters. Fixes #GH97878
476 - Clang now diagnoses dangling references to fields of temporary objects. Fixes #GH81589.
478 - Clang now diagnoses undefined behavior in constant expressions more consistently. This includes invalid shifts, and signed overflow in arithmetic.
480 - -Wdangling-assignment-gsl is enabled by default.
481 - Clang now always preserves the template arguments as written used
482 to specialize template type aliases.
484 - Clang now diagnoses the use of ``main`` in an ``extern`` context as invalid according to [basic.start.main] p3. Fixes #GH101512.
486 - Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.
488 - Don't emit duplicated dangling diagnostics. (#GH93386).
490 - Improved diagnostic when trying to befriend a concept. (#GH45182).
492 - Added the ``-Winvalid-gnu-asm-cast`` diagnostic group to control warnings
493 about use of "noop" casts for lvalues (a GNU extension). This diagnostic is
494 a warning which defaults to being an error, is enabled by default, and is
495 also controlled by the now-deprecated ``-fheinous-gnu-extensions`` flag.
497 - Added the ``-Wdecls-in-multiple-modules`` option to assist users to identify
498 multiple declarations in different modules, which is the major reason of the slow
499 compilation speed with modules. This warning is disabled by default and it needs
500 to be explicitly enabled or by ``-Weverything``.
502 - Improved diagnostic when trying to overload a function in an ``extern "C"`` context. (#GH80235)
504 - Clang now respects lifetimebound attribute for the assignment operator parameter. (#GH106372).
506 - The lifetimebound and GSL analysis in clang are coherent, allowing clang to
507 detect more use-after-free bugs. (#GH100549).
509 - Clang now diagnoses dangling cases where a gsl-pointer is constructed from a gsl-owner object inside a container (#GH100384).
511 - Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
513 - Clang now diagnose when importing module implementation partition units in module interface units.
515 - Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::lifetimebound]]` are used together (#GH108272).
517 - The ``-Wreturn-stack-address`` warning now also warns about addresses of
518 local variables passed to function calls using the ``[[clang::musttail]]``
521 - Clang now diagnoses cases where a dangling ``GSLOwner<GSLPointer>`` object is constructed, e.g. ``std::vector<string_view> v = {std::string()};`` (#GH100526).
523 - Clang now diagnoses when a ``requires`` expression has a local parameter of void type, aligning with the function parameter (#GH109831).
525 - Clang now emits a diagnostic note at the class declaration when the method definition does not match any declaration (#GH110638).
527 - Clang now omits warnings for extra parentheses in fold expressions with single expansion (#GH101863).
529 - The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``,
530 instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being
531 suboptimal in some way the error fails to mention (#GH111550).
533 - Clang now emits a ``-Wdepredcated-literal-operator`` diagnostic, even if the
534 name was a reserved name, which we improperly allowed to suppress the
537 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073).
539 - Improved diagnostic message for ``__builtin_bit_cast`` size mismatch (#GH115870).
541 - Clang now omits shadow warnings for enum constants in separate class scopes (#GH62588).
543 - When diagnosing an unused return value of a type declared ``[[nodiscard]]``, the type
544 itself is now included in the diagnostic.
546 - Clang will now prefer the ``[[nodiscard]]`` declaration on function declarations over ``[[nodiscard]]``
547 declaration on the return type of a function. Previously, when both have a ``[[nodiscard]]`` declaration attached,
548 the one on the return type would be preferred. This may affect the generated warning message:
552 struct [[nodiscard("Reason 1")]] S {};
553 [[nodiscard("Reason 2")]] S getS();
556 getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
559 - Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
561 Improvements to Clang's time-trace
562 ----------------------------------
564 Improvements to Coverage Mapping
565 --------------------------------
567 Bug Fixes in This Version
568 -------------------------
570 - Fixed the definition of ``ATOMIC_FLAG_INIT`` in ``<stdatomic.h>`` so it can
572 - Fixed a failed assertion when checking required literal types in C context. (#GH101304).
573 - Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685.
574 - Fixed a crash when diagnosing format strings and encountering an empty
575 delimited escape sequence (e.g., ``"\o{}"``). #GH102218
576 - Fixed a crash using ``__array_rank`` on 64-bit targets. (#GH113044).
577 - The warning emitted for an unsupported register variable type now points to
578 the unsupported type instead of the ``register`` keyword (#GH109776).
579 - Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
580 - Fixed a crash when GNU statement expression contains invalid statement (#GH113468).
581 - Fixed a failed assertion when using ``__attribute__((noderef))`` on an
582 ``_Atomic``-qualified type (#GH116124).
584 Bug Fixes to Compiler Builtins
585 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
587 - Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330)
589 - Clang now allows pointee types of atomic builtin arguments to be complete template types
590 that was not instantiated elsewhere.
592 - ``__noop`` can now be used in a constant expression. (#GH102064)
594 - Fix ``__has_builtin`` incorrectly returning ``false`` for some C++ type traits. (#GH111477)
596 Bug Fixes to Attribute Support
597 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
599 Bug Fixes to C++ Support
600 ^^^^^^^^^^^^^^^^^^^^^^^^
602 - Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646)
603 - Fixed incorrect pack expansion of init-capture references in requires expresssions.
604 - Fixed a failed assertion when checking invalid delete operator declaration. (#GH96191)
605 - Fix a crash when checking destructor reference with an invalid initializer. (#GH97230)
606 - Clang now correctly parses potentially declarative nested-name-specifiers in pointer-to-member declarators.
607 - Fix a crash when checking the initialzier of an object that was initialized
608 with a string literal. (#GH82167)
609 - Fix a crash when matching template template parameters with templates which have
610 parameters of different class type. (#GH101394)
611 - Clang now correctly recognizes the correct context for parameter
612 substitutions in concepts, so it doesn't incorrectly complain of missing
613 module imports in those situations. (#GH60336)
614 - Fix init-capture packs having a size of one before being instantiated. (#GH63677)
615 - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
617 - Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
618 - Fixed an assertion failure when selecting a function from an overload set that includes a
619 specialization of a conversion function template.
620 - Correctly diagnose attempts to use a concept name in its own definition;
621 A concept name is introduced to its scope sooner to match the C++ standard. (#GH55875)
622 - Properly reject defaulted relational operators with invalid types for explicit object parameters,
623 e.g., ``bool operator==(this int, const Foo&)`` (#GH100329), and rvalue reference parameters.
624 - Properly reject defaulted copy/move assignment operators that have a non-reference explicit object parameter.
625 - Clang now properly handles the order of attributes in `extern` blocks. (#GH101990).
626 - Fixed an assertion failure by preventing null explicit object arguments from being deduced. (#GH102025).
627 - Correctly check constraints of explicit instantiations of member functions. (#GH46029)
628 - When performing partial ordering of function templates, clang now checks that
629 the deduction was consistent. Fixes (#GH18291).
630 - Fixed an assertion failure about a constraint of a friend function template references to a value with greater
631 template depth than the friend function template. (#GH98258)
632 - Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
633 of the current instantiation in all cases.
634 - Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900)
635 - Correctly handle subexpressions of an immediate invocation in the presence of implicit casts. (#GH105558)
636 - Clang now correctly handles direct-list-initialization of a structured bindings from an array. (#GH31813)
637 - Mangle placeholders for deduced types as a template-prefix, such that mangling
638 of template template parameters uses the correct production. (#GH106182)
639 - Fixed an assertion failure when converting vectors to int/float with invalid expressions. (#GH105486)
640 - Template parameter names are considered in the name lookup of out-of-line class template
641 specialization right before its declaration context. (#GH64082)
642 - Fixed a constraint comparison bug for friend declarations. (#GH78101)
643 - Fix handling of ``_`` as the name of a lambda's init capture variable. (#GH107024)
644 - Fix an issue with dependent source location expressions (#GH106428), (#GH81155), (#GH80210), (#GH85373)
645 - Fixed a bug in the substitution of empty pack indexing types. (#GH105903)
646 - Clang no longer tries to capture non-odr used default arguments of template parameters of generic lambdas (#GH107048)
647 - Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588)
648 - Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134)
649 - A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361), (#GH112352)
650 - Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)
651 - Fixed a crash when clang tries to subtitute parameter pack while retaining the parameter
652 pack. (#GH63819), (#GH107560)
653 - Fix a crash when a static assert declaration has an invalid close location. (#GH108687)
654 - Avoided a redundant friend declaration instantiation under a certain ``consteval`` context. (#GH107175)
655 - Fixed an assertion failure in debug mode, and potential crashes in release mode, when
656 diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
657 - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
658 - Fixed a crash when mixture of designated and non-designated initializers in union. (#GH113855)
659 - Fixed an issue deducing non-type template arguments of reference type. (#GH73460)
660 - Fixed an issue in constraint evaluation, where type constraints on the lambda expression
661 containing outer unexpanded parameters were not correctly expanded. (#GH101754)
662 - Fixes crashes with function template member specializations, and increases
663 conformance of explicit instantiation behaviour with MSVC. (#GH111266)
664 - Fixed a bug in constraint expression comparison where the ``sizeof...`` expression was not handled properly
665 in certain friend declarations. (#GH93099)
666 - Clang now instantiates the correct lambda call operator when a lambda's class type is
667 merged across modules. (#GH110401)
668 - Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
669 - Fixed an assertion failure when invoking recovery call expressions with explicit attributes
670 and undeclared templates. (#GH107047), (#GH49093)
671 - Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded
672 parameter pack. (#GH109148)
673 - Fixed overload handling for object parameters with top-level cv-qualifiers in explicit member functions (#GH100394)
674 - Fixed a bug in lambda captures where ``constexpr`` class-type objects were not properly considered ODR-used in
675 certain situations. (#GH47400), (#GH90896)
676 - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441)
677 - During the lookup for a base class name, non-type names are ignored. (#GH16855)
678 - Fix a crash when recovering an invalid expression involving an explicit object member conversion operator. (#GH112559)
679 - Clang incorrectly considered a class with an anonymous union member to not be
680 const-default-constructible even if a union member has a default member initializer.
682 - Fixed an assertion failure when evaluating an invalid expression in an array initializer. (#GH112140)
683 - Fixed an assertion failure in range calculations for conditional throw expressions. (#GH111854)
684 - Clang now correctly ignores previous partial specializations of member templates explicitly specialized for
685 an implicitly instantiated class template specialization. (#GH51051)
686 - Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208)
687 - Name independent data members were not correctly initialized from default member initializers. (#GH114069)
688 - Fixed expression transformation for ``[[assume(...)]]``, allowing using pack indexing expressions within the
689 assumption if they also occur inside of a dependent lambda. (#GH114787)
690 - Clang now uses valid deduced type locations when diagnosing functions with trailing return type
691 missing placeholder return type. (#GH78694)
693 Bug Fixes to AST Handling
694 ^^^^^^^^^^^^^^^^^^^^^^^^^
696 - Fixed a crash that occurred when dividing by zero in complex integer division. (#GH55390).
697 - Fixed a bug in ``ASTContext::getRawCommentForAnyRedecl()`` where the function could
698 sometimes incorrectly return null even if a comment was present. (#GH108145)
699 - Clang now correctly parses the argument of the ``relates``, ``related``, ``relatesalso``,
700 and ``relatedalso`` comment commands.
702 Miscellaneous Bug Fixes
703 ^^^^^^^^^^^^^^^^^^^^^^^
705 Miscellaneous Clang Crashes Fixed
706 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
708 - Fixed a crash in C due to incorrect lookup that members in nested anonymous struct/union
709 can be found as ordinary identifiers in struct/union definition. (#GH31295)
711 - Fixed a crash caused by long chains of ``sizeof`` and other similar operators
712 that can be followed by a non-parenthesized expression. (#GH45061)
714 - Fixed an crash when compiling ``#pragma STDC FP_CONTRACT DEFAULT`` with
715 ``-ffp-contract=fast-honor-pragmas``. (#GH104830)
717 - Fixed a crash when function has more than 65536 parameters.
718 Now a diagnostic is emitted. (#GH35741)
720 - Fixed ``-ast-dump`` crashes on codes involving ``concept`` with ``-ast-dump-decl-types``. (#GH94928)
722 - Fixed internal assertion firing when a declaration in the implicit global
723 module is found through ADL. (GH#109879)
725 OpenACC Specific Changes
726 ------------------------
728 Target Specific Changes
729 -----------------------
731 - Clang now implements the Solaris-specific mangling of ``std::tm`` as
732 ``tm``, same for ``std::div_t``, ``std::ldiv_t``, and
733 ``std::lconv``, for Solaris ABI compatibility. (#GH33114)
738 - Initial support for gfx950
740 - Added headers ``gpuintrin.h`` and ``amdgpuintrin.h`` that contains common
741 definitions for GPU builtin functions. This header can be included for OpenMP,
742 CUDA, HIP, OpenCL, and C/C++.
747 - Added headers ``gpuintrin.h`` and ``nvptxintrin.h`` that contains common
748 definitions for GPU builtin functions. This header can be included for OpenMP,
749 CUDA, HIP, OpenCL, and C/C++.
754 - The MMX vector intrinsic functions from ``*mmintrin.h`` which
755 operate on `__m64` vectors, such as ``_mm_add_pi8``, have been
756 reimplemented to use the SSE2 instruction-set and XMM registers
757 unconditionally. These intrinsics are therefore *no longer
758 supported* if MMX is enabled without SSE2 -- either from targeting
759 CPUs from the Pentium-MMX through the Pentium 3, or explicitly via
760 passing arguments such as ``-mmmx -mno-sse2``. MMX assembly code
761 remains supported without requiring SSE2, including inside
764 - The compiler builtins such as ``__builtin_ia32_paddb`` which
765 formerly implemented the above MMX intrinsic functions have been
766 removed. Any uses of these removed functions should migrate to the
767 functions defined by the ``*mmintrin.h`` headers. A mapping can be
768 found in the file ``clang/www/builtins.py``.
770 - Support ISA of ``AVX10.2``.
771 * Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
772 ``*_(mask(z)))_minmax_s[s|d|h]``.
774 - Supported intrinsics for ``SM4 and AVX10.2``.
775 * Supported SM4 intrinsics of ``_mm512_sm4key4_epi32`` and
776 ``_mm512_sm4rnds4_epi32``.
778 - All intrinsics in adcintrin.h can now be used in constant expressions.
780 - All intrinsics in adxintrin.h can now be used in constant expressions.
782 - All intrinsics in lzcntintrin.h can now be used in constant expressions.
784 - All intrinsics in bmiintrin.h can now be used in constant expressions.
786 - All intrinsics in bmi2intrin.h can now be used in constant expressions.
788 - All intrinsics in tbmintrin.h can now be used in constant expressions.
790 - Supported intrinsics for ``MOVRS AND AVX10.2``.
791 * Supported intrinsics of ``_mm(256|512)_(mask(z))_loadrs_epi(8|16|32|64)``.
792 - Support ISA of ``AMX-FP8``.
793 - Support ISA of ``AMX-TRANSPOSE``.
794 - Support ISA of ``AMX-MOVRS``.
795 - Support ISA of ``AMX-AVX512``.
796 - Support ISA of ``AMX-TF32``.
797 - Support ISA of ``MOVRS``.
799 - Supported ``-march/tune=diamondrapids``
801 Arm and AArch64 Support
802 ^^^^^^^^^^^^^^^^^^^^^^^
804 - In the ARM Target, the frame pointer (FP) of a leaf function can be retained
805 by using the ``-fno-omit-frame-pointer`` option. If you want to eliminate the FP
806 in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding
807 the ``-momit-leaf-frame-pointer`` option.
815 - clang-cl now supports ``/std:c++23preview`` which enables C++23 features.
817 - Clang no longer allows references inside a union when emulating MSVC 1900+ even if `fms-extensions` is enabled.
818 Starting with VS2015, MSVC 1900, this Microsoft extension is no longer allowed and always results in an error.
819 Clang now follows the MSVC behavior in this scenario.
820 When `-fms-compatibility-version=18.00` or prior is set on the command line this Microsoft extension is still
821 allowed as VS2013 and prior allow it.
829 - The option ``-mcmodel=large`` for the large code model is supported.
831 CUDA/HIP Language Changes
832 ^^^^^^^^^^^^^^^^^^^^^^^^^
836 - Clang now supports CUDA SDK up to 12.6
837 - Added support for sm_100
838 - Added support for `__grid_constant__` attribute.
849 The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
850 and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
851 and [Non-trapping float-to-int Conversions] language features, which are
852 [widely implemented in engines].
854 [Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
855 [Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
856 [widely implemented in engines]: https://webassembly.org/features/
861 - Reject C/C++ compilation for avr1 devices which have no SRAM.
863 DWARF Support in Clang
864 ----------------------
866 Floating Point Support in Clang
867 -------------------------------
869 - Add ``__builtin_elementwise_atan2`` builtin for floating point types only.
871 Fixed Point Support in Clang
872 ----------------------------
877 - Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
878 inline namespaces with an enclosing namespace of the same name.
880 - Fixed an ordering issue with the `hasOperands` matcher occurring when setting a
881 binding in the first matcher and using it in the second matcher.
883 - Fixed a crash when traverse lambda expr with invalid captures. (#GH106444)
885 - Fixed ``isInstantiated`` and ``isInTemplateInstantiation`` to also match for variable templates. (#GH110666)
887 - Ensure ``hasName`` matches template specializations across inline namespaces,
888 making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent.
893 - Adds ``BreakBinaryOperations`` option.
894 - Adds ``TemplateNames`` option.
895 - Adds ``AlignFunctionDeclarations`` option to ``AlignConsecutiveDeclarations``.
896 - Adds ``IndentOnly`` suboption to ``ReflowComments`` to fix the indentation of
897 multi-line comments without touching their contents, renames ``false`` to
898 ``Never``, and ``true`` to ``Always``.
899 - Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
900 - Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
904 - Add ``clang_isBeforeInTranslationUnit``. Given two source locations, it determines
905 whether the first one comes strictly before the second in the source code.
913 - Now CSA models `__builtin_*_overflow` functions. (#GH102602)
915 - MallocChecker now checks for ``ownership_returns(class, idx)`` and ``ownership_takes(class, idx)``
916 attributes with class names different from "malloc". Clang static analyzer now reports an error
917 if class of allocation and deallocation function mismatches.
918 `Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#unix-mismatcheddeallocator-c-c>`__.
920 - Function effects, e.g. the ``nonblocking`` and ``nonallocating`` "performance constraint"
921 attributes, are now verified. For example, for functions declared with the ``nonblocking``
922 attribute, the compiler can generate warnings about the use of any language features, or calls to
923 other functions, which may block.
925 - Introduced ``-warning-suppression-mappings`` flag to control diagnostic
926 suppressions per file. See `documentation <https://clang.llvm.org/docs/WarningSuppressionMappings.html>_` for details.
934 - Improved the handling of the ``ownership_returns`` attribute. Now, Clang reports an
935 error if the attribute is attached to a function that returns a non-pointer value.
941 - The checker ``alpha.security.MallocOverflow`` was deleted because it was
942 badly implemented and its agressive logic produced too many false positives.
943 To detect too large arguments passed to malloc, consider using the checker
944 ``alpha.taint.TaintedAlloc``.
946 - The checkers ``alpha.nondeterministic.PointerSorting`` and
947 ``alpha.nondeterministic.PointerIteration`` were moved to a new bugprone
948 checker named ``bugprone-nondeterministic-pointer-iteration-order``. The
949 original checkers were implemented only using AST matching and make more
950 sense as a single clang-tidy check.
952 .. _release-notes-sanitizers:
956 - Introduced Realtime Sanitizer, activated by using the -fsanitize=realtime
957 flag. This sanitizer detects unsafe system library calls, such as memory
958 allocations and mutex locks. If any such function is called during invocation
959 of a function marked with the ``[[clang::nonblocking]]`` attribute, an error
960 is printed to the console and the process exits non-zero.
962 - Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
963 used to disable specific overflow-dependent code patterns. The supported
964 patterns are: ``add-signed-overflow-test``, ``add-unsigned-overflow-test``,
965 ``negated-unsigned-const``, and ``unsigned-post-decr-while``. The sanitizer
966 instrumentation can be toggled off for all available patterns by specifying
967 ``all``. Conversely, you may disable all exclusions with ``none`` which is
972 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-unsigned-overflow-test``
973 int common_overflow_check_pattern(unsigned base, unsigned offset) {
974 if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
977 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-signed-overflow-test``
978 int common_overflow_check_pattern_signed(signed int base, signed int offset) {
979 if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
982 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const``
983 void negation_overflow() {
984 unsigned long foo = -1UL; // No longer causes a negation overflow warning
985 unsigned long bar = -2UL; // and so on...
988 /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=unsigned-post-decr-while``
989 void while_post_decrement() {
990 unsigned char count = 16;
991 while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
994 Many existing projects have a large amount of these code patterns present.
995 This new flag should allow those projects to enable integer sanitizers with
998 - ``-fsanitize=signed-integer-overflow``, ``-fsanitize=unsigned-integer-overflow``,
999 ``-fsanitize=implicit-signed-integer-truncation``, ``-fsanitize=implicit-unsigned-integer-truncation``,
1000 ``-fsanitize=enum`` now properly support the
1001 "type" prefix within `Sanitizer Special Case Lists (SSCL)
1002 <https://clang.llvm.org/docs/SanitizerSpecialCaseList.html>`_. See that link
1005 Python Binding Changes
1006 ----------------------
1007 - Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.
1011 - Added support for 'omp assume' directive.
1012 - Added support for 'omp scope' directive.
1013 - Added support for allocator-modifier in 'allocate' clause.
1017 - Improve the handling of mapping array-section for struct containing nested structs with user defined mappers
1019 - `num_teams` and `thead_limit` now accept multiple expressions when it is used
1020 along in ``target teams ompx_bare`` construct. This allows the target region
1021 to be launched with multi-dim grid on GPUs.
1023 Additional Information
1024 ======================
1026 A wide variety of additional information is available on the `Clang web
1027 page <https://clang.llvm.org/>`_. The web page contains versions of the
1028 API documentation which are up-to-date with the Git version of
1029 the source code. You can access versions of these documents specific to
1030 this release by going into the "``clang/docs/``" directory in the Clang
1033 If you have any questions or comments about Clang, please feel free to
1034 contact us on the `Discourse forums (Clang Frontend category)
1035 <https://discourse.llvm.org/c/clang/6>`_.