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
41 C/C++ Language Potentially Breaking Changes
42 -------------------------------------------
44 - The default extension name for PCH generation (``-c -xc-header`` and ``-c
45 -xc++-header``) is now ``.pch`` instead of ``.gch``.
46 - ``-include a.h`` probing ``a.h.gch`` will now ignore ``a.h.gch`` if it is not
47 a clang pch file or a directory containing any clang pch file.
48 - Fixed a bug that caused ``__has_cpp_attribute`` and ``__has_c_attribute``
49 return incorrect values for some C++-11-style attributes. Below is a complete
50 list of behavior changes.
53 :header: Test, Old value, New value
55 ``__has_cpp_attribute(unused)``, 201603, 0
56 ``__has_cpp_attribute(gnu::unused)``, 201603, 1
57 ``__has_c_attribute(unused)``, 202106, 0
58 ``__has_cpp_attribute(clang::fallthrough)``, 201603, 1
59 ``__has_cpp_attribute(gnu::fallthrough)``, 201603, 1
60 ``__has_c_attribute(gnu::fallthrough)``, 201910, 1
61 ``__has_cpp_attribute(warn_unused_result)``, 201907, 0
62 ``__has_cpp_attribute(clang::warn_unused_result)``, 201907, 1
63 ``__has_cpp_attribute(gnu::warn_unused_result)``, 201907, 1
64 ``__has_c_attribute(warn_unused_result)``, 202003, 0
65 ``__has_c_attribute(gnu::warn_unused_result)``, 202003, 1
67 - Fixed a bug in finding matching `operator!=` while adding reversed `operator==` as
68 outlined in "The Equality Operator You Are Looking For" (`P2468 <http://wg21.link/p2468r2>`_).
69 Fixes (`#68901: <https://github.com/llvm/llvm-project/issues/68901>`_).
71 C++ Specific Potentially Breaking Changes
72 -----------------------------------------
73 - The name mangling rules for function templates has been changed to take into
74 account the possibility that functions could be overloaded on their template
75 parameter lists or requires-clauses. This causes mangled names to change for
76 function templates in the following cases:
78 - When a template parameter in a function template depends on a previous
79 template parameter, such as ``template<typename T, T V> void f()``.
80 - When the function has any constraints, whether from constrained template
81 parameters or requires-clauses.
82 - When the template parameter list includes a deduced type -- either
83 ``auto``, ``decltype(auto)``, or a deduced class template specialization
85 - When a template template parameter is given a template template argument
86 that has a different template parameter list.
88 This fixes a number of issues where valid programs would be rejected due to
89 mangling collisions, or would in some cases be silently miscompiled. Clang
90 will use the old manglings if ``-fclang-abi-compat=17`` or lower is
92 (`#48216 <https://github.com/llvm/llvm-project/issues/48216>`_),
93 (`#49884 <https://github.com/llvm/llvm-project/issues/49884>`_), and
94 (`#61273 <https://github.com/llvm/llvm-project/issues/61273>`_)
96 - The `ClassScopeFunctionSpecializationDecl` AST node has been removed.
97 Dependent class scope explicit function template specializations now use
98 `DependentFunctionTemplateSpecializationInfo` to store candidate primary
99 templates and explicit template arguments. This should not impact users of
100 Clang as a compiler, but it may break assumptions in Clang-based tools
101 iterating over the AST.
103 - The warning `-Wenum-constexpr-conversion` is now also enabled by default on
104 system headers and macros. It will be turned into a hard (non-downgradable)
105 error in the next Clang release.
107 - The flag `-fdelayed-template-parsing` won't be enabled by default with C++20
108 when targetting MSVC to match the behavior of MSVC.
109 (`MSVC Docs <https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170>`_)
111 ABI Changes in This Version
112 ---------------------------
113 - Following the SystemV ABI for x86-64, ``__int128`` arguments will no longer
114 be split between a register and a stack slot.
116 AST Dumping Potentially Breaking Changes
117 ----------------------------------------
118 - When dumping a sugared type, Clang will no longer print the desugared type if
119 its textual representation is the same as the sugared one. This applies to
120 both text dumps of the form ``'foo':'foo'`` which will now be dumped as just
121 ``'foo'``, and JSON dumps of the form:
127 "desugaredQualType": "foo"
130 which will now be dumped as just:
138 What's New in Clang |release|?
139 ==============================
140 Some of the major new features and improvements to Clang are listed
141 here. Generic improvements to Clang as a whole or to its underlying
142 infrastructure are described first, followed by language-specific
143 sections with improvements to Clang's support for those languages.
148 C++20 Feature Support
149 ^^^^^^^^^^^^^^^^^^^^^
151 C++23 Feature Support
152 ^^^^^^^^^^^^^^^^^^^^^
153 - Implemented `P0847R7: Deducing this <https://wg21.link/P0847R7>`_. Some related core issues were also
154 implemented (`CWG2553 <https://wg21.link/CWG2553>`_, `CWG2554 <https://wg21.link/CWG2554>`_,
155 `CWG2653 <https://wg21.link/CWG2653>`_, `CWG2687 <https://wg21.link/CWG2687>`_). Because the
156 support for this feature is still experimental, the feature test macro ``__cpp_explicit_this_parameter``
157 was not set in this version.
159 C++2c Feature Support
160 ^^^^^^^^^^^^^^^^^^^^^
162 - Implemented `P2169R4: A nice placeholder with no name <https://wg21.link/P2169R4>`_. This allows using ``_``
163 as a variable name multiple times in the same scope and is supported in all C++ language modes as an extension.
164 An extension warning is produced when multiple variables are introduced by ``_`` in the same scope.
165 Unused warnings are no longer produced for variables named ``_``.
166 Currently, inspecting placeholders variables in a debugger when more than one are declared in the same scope
172 int _, _; // Was invalid, now OK
175 int _, _; // Was invalid, now OK
178 int _; // Previously diagnosed under -Wunused, no longer diagnosed
181 - Attributes now expect unevaluated strings in attributes parameters that are string literals.
182 This is applied to both C++ standard attributes, and other attributes supported by Clang.
183 This completes the implementation of `P2361R6 Unevaluated Strings <https://wg21.link/P2361R6>`_
185 - Implemented `P2864R2 Remove Deprecated Arithmetic Conversion on Enumerations From C++26 <https://wg21.link/P2864R2>`_.
187 - Implemented `P2361R6 Template parameter initialization <https://wg21.link/P2308R1>`_.
188 This change is applied as a DR in all language modes.
191 Resolutions to C++ Defect Reports
192 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196 - ``structs``, ``unions``, and ``arrays`` that are const may now be used as
197 constant expressions. This change is more consistent with the behavior of
199 - Clang now supports the C-only attribute ``counted_by``. When applied to a
200 struct's flexible array member, it points to the struct field that holds the
201 number of elements in the flexible array member. This information can improve
202 the results of the array bound sanitizer and the
203 ``__builtin_dynamic_object_size`` builtin.
207 - Clang now accepts ``-std=c23`` and ``-std=gnu23`` as language standard modes,
208 and the ``__STDC_VERSION__`` macro now expands to ``202311L`` instead of its
209 previous placeholder value. Clang continues to accept ``-std=c2x`` and
210 ``-std=gnu2x`` as aliases for C23 and GNU C23, respectively.
211 - Clang now supports `requires c23` for module maps.
212 - Clang now supports ``N3007 Type inference for object definitions``.
214 - Clang now supports ``<stdckdint.h>`` which defines several macros for performing
215 checked integer arithmetic. It is also exposed in pre-C23 modes.
217 - Completed the implementation of
218 `N2508 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2508.pdf>`_. We
219 previously implemented allowing a label at the end of a compound statement,
220 and now we've implemented allowing a label to be followed by a declaration
221 instead of a statement.
223 Non-comprehensive list of changes in this release
224 -------------------------------------------------
226 * Clang now has a ``__builtin_vectorelements()`` function that determines the number of elements in a vector.
227 For fixed-sized vectors, e.g., defined via ``__attribute__((vector_size(N)))`` or ARM NEON's vector types
228 (e.g., ``uint16x8_t``), this returns the constant number of elements at compile-time.
229 For scalable vectors, e.g., SVE or RISC-V V, the number of elements is not known at compile-time and is
230 determined at runtime.
231 * The ``__datasizeof`` keyword has been added. It is similar to ``sizeof``
232 except that it returns the size of a type ignoring tail padding.
233 * ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the return value ``18``
234 and vector types as return value ``19``, to match GCC 14's behavior.
236 * Added ``#pragma clang fp reciprocal``.
241 * ``-fverify-intermediate-code`` and its complement ``-fno-verify-intermediate-code``.
242 Enables or disables verification of the generated LLVM IR.
243 Users can pass this to turn on extra verification to catch certain types of
244 compiler bugs at the cost of extra compile time.
245 Since enabling the verifier adds a non-trivial cost of a few percent impact on
246 build times, it's disabled by default, unless your LLVM distribution itself is
247 compiled with runtime checks enabled.
248 * ``-fkeep-system-includes`` modifies the behavior of the ``-E`` option,
249 preserving ``#include`` directives for "system" headers instead of copying
250 the preprocessed text to the output. This can greatly reduce the size of the
251 preprocessed output, which can be helpful when trying to reduce a test case.
252 * ``-fassume-nothrow-exception-dtor`` is added to assume that the destructor of
253 an thrown exception object will not throw. The generated code for catch
254 handlers will be smaller. A throw expression of a type with a
255 potentially-throwing destructor will lead to an error.
257 * ``-fopenacc`` was added as a part of the effort to support OpenACC in clang.
259 Deprecated Compiler Flags
260 -------------------------
262 Modified Compiler Flags
263 -----------------------
265 * ``-Woverriding-t-option`` is renamed to ``-Woverriding-option``.
266 * ``-Winterrupt-service-routine`` is renamed to ``-Wexcessive-regsave`` as a generalization
267 * ``-frewrite-includes`` now guards the original #include directives with
268 ``__CLANG_REWRITTEN_INCLUDES``, and ``__CLANG_REWRITTEN_SYSTEM_INCLUDES`` as
270 * Introducing a new default calling convention for ``-fdefault-calling-conv``:
271 ``rtdcall``. This new default CC only works for M68k and will use the new
272 ``m68k_rtdcc`` CC on every functions that are not variadic. The ``-mrtd``
273 driver/frontend flag has the same effect when targeting M68k.
275 Removed Compiler Flags
276 -------------------------
278 * ``-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang`` has been removed.
279 It has not been needed to enable ``-ftrivial-auto-var-init=zero`` since Clang 16.
281 Attribute Changes in Clang
282 --------------------------
283 - On X86, a warning is now emitted if a function with ``__attribute__((no_caller_saved_registers))``
284 calls a function without ``__attribute__((no_caller_saved_registers))``, and is not compiled with
285 ``-mgeneral-regs-only``
286 - On X86, a function with ``__attribute__((interrupt))`` can now call a function without
287 ``__attribute__((no_caller_saved_registers))`` provided that it is compiled with ``-mgeneral-regs-only``
289 - When a non-variadic function is decorated with the ``format`` attribute,
290 Clang now checks that the format string would match the function's parameters'
291 types after default argument promotion. As a result, it's no longer an
292 automatic diagnostic to use parameters of types that the format style
293 supports but that are never the result of default argument promotion, such as
294 ``float``. (`#59824: <https://github.com/llvm/llvm-project/issues/59824>`_)
296 - Clang now supports ``[[clang::preferred_type(type-name)]]`` as an attribute
297 which can be applied to a bit-field. This attribute helps to map a bit-field
298 back to a particular type that may be better-suited to representing the bit-
299 field but cannot be used for other reasons and will impact the debug
300 information generated for the bit-field. This is most useful when mapping a
301 bit-field of basic integer type back to a ``bool`` or an enumeration type,
306 enum E { Apple, Orange, Pear };
308 [[clang::preferred_type(E)]] unsigned FruitKind : 2;
311 When viewing ``S::FruitKind`` in a debugger, it will behave as if the member
312 was declared as type ``E`` rather than ``unsigned``.
314 - Clang now warns you that the ``_Alignas`` attribute on declaration specifiers
315 is ignored, changed from the former incorrect suggestion to move it past
316 declaration specifiers. (`#58637 <https://github.com/llvm/llvm-project/issues/58637>`_)
318 - Clang now introduced ``[[clang::coro_only_destroy_when_complete]]`` attribute
319 to reduce the size of the destroy functions for coroutines which are known to
320 be destroyed after having reached the final suspend point.
322 - Clang now introduced ``[[clang::coro_return_type]]`` and ``[[clang::coro_wrapper]]``
323 attributes. A function returning a type marked with ``[[clang::coro_return_type]]``
324 should be a coroutine. A non-coroutine function marked with ``[[clang::coro_wrapper]]``
325 is still allowed to return the such a type. This is helpful for analyzers to recognize coroutines from the function signatures.
327 - Clang now supports ``[[clang::code_align(N)]]`` as an attribute which can be
328 applied to a loop and specifies the byte alignment for a loop. This attribute
329 accepts a positive integer constant initialization expression indicating the
330 number of bytes for the minimum alignment boundary. Its value must be a power
331 of 2, between 1 and 4096(inclusive).
335 void Array(int *array, size_t n) {
336 [[clang::code_align(64)]] for (int i = 0; i < n; ++i) array[i] = 0;
341 [[clang::code_align(A)]] for(;;) { }
344 - Clang now introduced ``[[clang::coro_lifetimebound]]`` attribute.
345 All parameters of a function are considered to be lifetime bound if the function
346 returns a type annotated with ``[[clang::coro_lifetimebound]]`` and ``[[clang::coro_return_type]]``.
348 Improvements to Clang's diagnostics
349 -----------------------------------
350 - Clang constexpr evaluator now prints template arguments when displaying
351 template-specialization function calls.
352 - Clang contexpr evaluator now displays notes as well as an error when a constructor
353 of a base class is not called in the constructor of its derived class.
354 - Clang no longer emits ``-Wmissing-variable-declarations`` for variables declared
355 with the ``register`` storage class.
356 - Clang's ``-Wtautological-negation-compare`` flag now diagnoses logical
357 tautologies like ``x && !x`` and ``!x || x`` in expressions. This also
358 makes ``-Winfinite-recursion`` diagnose more cases.
359 (`#56035: <https://github.com/llvm/llvm-project/issues/56035>`_).
360 - Clang constexpr evaluator now diagnoses compound assignment operators against
361 uninitialized variables as a read of uninitialized object.
362 (`#51536 <https://github.com/llvm/llvm-project/issues/51536>`_)
363 - Clang's ``-Wformat-truncation`` now diagnoses ``snprintf`` call that is known to
364 result in string truncation.
365 (`#64871: <https://github.com/llvm/llvm-project/issues/64871>`_).
366 Existing warnings that similarly warn about the overflow in ``sprintf``
367 now falls under its own warning group ```-Wformat-overflow`` so that it can
368 be disabled separately from ``Wfortify-source``.
369 These two new warning groups have subgroups ``-Wformat-truncation-non-kprintf``
370 and ``-Wformat-overflow-non-kprintf``, respectively. These subgroups are used when
371 the format string contains ``%p`` format specifier.
372 Because Linux kernel's codebase has format extensions for ``%p``, kernel developers
373 are encouraged to disable these two subgroups by setting ``-Wno-format-truncation-non-kprintf``
374 and ``-Wno-format-overflow-non-kprintf`` in order to avoid false positives on
376 Also clang no longer emits false positive warnings about the output length of
377 ``%g`` format specifier and about ``%o, %x, %X`` with ``#`` flag.
378 - Clang now emits ``-Wcast-qual`` for functional-style cast expressions.
379 - Clang no longer emits irrelevant notes about unsatisfied constraint expressions
380 on the left-hand side of ``||`` when the right-hand side constraint is satisfied.
381 (`#54678: <https://github.com/llvm/llvm-project/issues/54678>`_).
382 - Clang now prints its 'note' diagnostic in cyan instead of black, to be more compatible
383 with terminals with dark background colors. This is also more consistent with GCC.
384 - The fix-it emitted by ``-Wformat`` for scoped enumerations now take the
385 enumeration's underlying type into account instead of suggesting a type just
386 based on the format string specifier being used.
387 - Clang now displays an improved diagnostic and a note when a defaulted special
388 member is marked ``constexpr`` in a class with a virtual base class
389 (`#64843: <https://github.com/llvm/llvm-project/issues/64843>`_).
390 - ``-Wfixed-enum-extension`` and ``-Wmicrosoft-fixed-enum`` diagnostics are no longer
391 emitted when building as C23, since C23 standardizes support for enums with a
392 fixed underlying type.
393 - When describing the failure of static assertion of `==` expression, clang prints the integer
394 representation of the value as well as its character representation when
395 the user-provided expression is of character type. If the character is
396 non-printable, clang now shows the escpaed character.
397 Clang also prints multi-byte characters if the user-provided expression
398 is of multi-byte character type.
404 static_assert("A\n"[1] == U'🌍');
410 source:1:15: error: static assertion failed due to requirement '"A\n"[1] == U'\U0001f30d''
411 1 | static_assert("A\n"[1] == U'🌍');
413 source:1:24: note: expression evaluates to ''
415 1 | static_assert("A\n"[1] == U'🌍');
422 source:1:15: error: static assertion failed due to requirement '"A\n"[1] == U'\U0001f30d''
423 1 | static_assert("A\n"[1] == U'🌍');
425 source:1:24: note: expression evaluates to ''\n' (0x0A, 10) == U'🌍' (0x1F30D, 127757)'
426 1 | static_assert("A\n"[1] == U'🌍');
428 - Clang now always diagnoses when using non-standard layout types in ``offsetof`` .
429 (`#64619: <https://github.com/llvm/llvm-project/issues/64619>`_)
430 - Clang now diagnoses redefined defaulted constructor when redefined
431 defaulted constructor with different exception specs.
432 (`#69094: <https://github.com/llvm/llvm-project/issues/69094>`_)
433 - Clang now diagnoses use of variable-length arrays in C++ by default (and
434 under ``-Wall`` in GNU++ mode). This is an extension supported by Clang and
435 GCC, but is very easy to accidentally use without realizing it's a
436 nonportable construct that has different semantics from a constant-sized
437 array. (`#62836 <https://github.com/llvm/llvm-project/issues/62836>`_)
439 - Clang changed the order in which it displays candidate functions on overloading failures.
440 Previously, Clang used definition of ordering from the C++ Standard. The order defined in
441 the Standard is partial and is not suited for sorting. Instead, Clang now uses a strict
442 order that still attempts to push more relevant functions to the top by comparing their
443 corresponding conversions. In some cases, this results in better order. E.g., for the
450 operator const char*();
453 void test() { Foo() - Foo(); }
455 Clang now produces a list with two most relevant builtin operators at the top,
456 i.e. ``operator-(int, int)`` and ``operator-(const char*, const char*)``.
457 Previously ``operator-(const char*, const char*)`` was the first element,
458 but ``operator-(int, int)`` was only the 13th element in the output.
459 However, new implementation does not take into account some aspects of
460 C++ semantics, e.g. which function template is more specialized. This
461 can sometimes lead to worse ordering.
464 - When describing a warning/error in a function-style type conversion Clang underlines only until
465 the end of the expression we convert from. Now Clang underlines until the closing parenthesis.
471 warning: cast from 'long (*)(const int &)' to 'decltype(fun_ptr)' (aka 'long (*)(int &)') converts to incompatible function type [-Wcast-function-type-strict]
472 24 | return decltype(fun_ptr)( f_ptr /*comment*/);
473 | ^~~~~~~~~~~~~~~~~~~~~~~~
479 warning: cast from 'long (*)(const int &)' to 'decltype(fun_ptr)' (aka 'long (*)(int &)') converts to incompatible function type [-Wcast-function-type-strict]
480 24 | return decltype(fun_ptr)( f_ptr /*comment*/);
481 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
483 - ``-Wzero-as-null-pointer-constant`` diagnostic is no longer emitted when using ``__null``
484 (or, more commonly, ``NULL`` when the platform defines it as ``__null``) to be more consistent
486 - Clang will warn on deprecated specializations used in system headers when their instantiation
487 is caused by user code.
488 - Clang will now print ``static_assert`` failure details for arithmetic binary operators.
493 static_assert(1 << 4 == 15);
499 error: static assertion failed due to requirement '1 << 4 == 15'
500 48 | static_assert(1 << 4 == 15);
502 note: expression evaluates to '16 == 15'
503 48 | static_assert(1 << 4 == 15);
507 Improvements to Clang's time-trace
508 ----------------------------------
509 - Two time-trace scope variables are added. A time trace scope variable of
510 ``ParseDeclarationOrFunctionDefinition`` with the function's source location
511 is added to record the time spent parsing the function's declaration or
512 definition. Another time trace scope variable of ``ParseFunctionDefinition``
513 is also added to record the name of the defined function.
515 Bug Fixes in This Version
516 -------------------------
517 - Fixed an issue where a class template specialization whose declaration is
518 instantiated in one module and whose definition is instantiated in another
519 module may end up with members associated with the wrong declaration of the
520 class, which can result in miscompiles in some cases.
521 - Fix crash on use of a variadic overloaded operator.
522 (`#42535 <https://github.com/llvm/llvm-project/issues/42535>`_)
523 - Fix a hang on valid C code passing a function type as an argument to
524 ``typeof`` to form a function declaration.
525 (`#64713 <https://github.com/llvm/llvm-project/issues/64713>`_)
526 - Clang now reports missing-field-initializers warning for missing designated
528 (`#56628 <https://github.com/llvm/llvm-project/issues/56628>`_)
529 - Clang now respects ``-fwrapv`` and ``-ftrapv`` for ``__builtin_abs`` and
531 (`#45129 <https://github.com/llvm/llvm-project/issues/45129>`_,
532 `#45794 <https://github.com/llvm/llvm-project/issues/45794>`_)
533 - Fixed an issue where accesses to the local variables of a coroutine during
534 ``await_suspend`` could be misoptimized, including accesses to the awaiter
536 (`#56301 <https://github.com/llvm/llvm-project/issues/56301>`_)
537 The current solution may bring performance regressions if the awaiters have
538 non-static data members. See
539 `#64945 <https://github.com/llvm/llvm-project/issues/64945>`_ for details.
540 - Clang now prints unnamed members in diagnostic messages instead of giving an
542 (`#63759 <https://github.com/llvm/llvm-project/issues/63759>`_)
543 - Fix crash in __builtin_strncmp and related builtins when the size value
544 exceeded the maximum value representable by int64_t. Fixes
545 (`#64876 <https://github.com/llvm/llvm-project/issues/64876>`_)
546 - Fixed an assertion if a function has cleanups and fatal erors.
547 (`#48974 <https://github.com/llvm/llvm-project/issues/48974>`_)
548 - Clang now emits an error if it is not possible to deduce array size for a
549 variable with incomplete array type.
550 (`#37257 <https://github.com/llvm/llvm-project/issues/37257>`_)
551 - Clang's ``-Wunused-private-field`` no longer warns on fields whose type is
552 declared with ``[[maybe_unused]]``.
553 (`#61334 <https://github.com/llvm/llvm-project/issues/61334>`_)
554 - For function multi-versioning using the ``target``, ``target_clones``, or
555 ``target_version`` attributes, remove comdat for internal linkage functions.
556 (`#65114 <https://github.com/llvm/llvm-project/issues/65114>`_)
557 - Clang now reports ``-Wformat`` for bool value and char specifier confusion
559 (`#64987 <https://github.com/llvm/llvm-project/issues/64987>`_)
560 - Support MSVC predefined macro expressions in constant expressions and in
562 - Correctly parse non-ascii identifiers that appear immediately after a line splicing
563 (`#65156 <https://github.com/llvm/llvm-project/issues/65156>`_)
564 - Clang no longer considers the loss of ``__unaligned`` qualifier from objects as
565 an invalid conversion during method function overload resolution.
566 - Fix lack of comparison of declRefExpr in ASTStructuralEquivalence
567 (`#66047 <https://github.com/llvm/llvm-project/issues/66047>`_)
568 - Fix parser crash when dealing with ill-formed objective C++ header code. Fixes
569 (`#64836 <https://github.com/llvm/llvm-project/issues/64836>`_)
570 - Fix crash in implicit conversions from initialize list to arrays of unknown
571 bound for C++20. Fixes
572 (`#62945 <https://github.com/llvm/llvm-project/issues/62945>`_)
573 - Clang now allows an ``_Atomic`` qualified integer in a switch statement. Fixes
574 (`#65557 <https://github.com/llvm/llvm-project/issues/65557>`_)
575 - Fixes crash when trying to obtain the common sugared type of
576 `decltype(instantiation-dependent-expr)`.
577 Fixes (`#67603 <https://github.com/llvm/llvm-project/issues/67603>`_)
578 - Fixes a crash caused by a multidimensional array being captured by a lambda
579 (`#67722 <https://github.com/llvm/llvm-project/issues/67722>`_).
580 - Fixes a crash when instantiating a lambda with requires clause.
581 (`#64462 <https://github.com/llvm/llvm-project/issues/64462>`_)
582 - Fixes a regression where the ``UserDefinedLiteral`` was not properly preserved
583 while evaluating consteval functions. (`#63898 <https://github.com/llvm/llvm-project/issues/63898>`_).
584 - Fix a crash when evaluating value-dependent structured binding
585 variables at compile time.
586 Fixes (`#67690 <https://github.com/llvm/llvm-project/issues/67690>`_)
587 - Fixes a ``clang-17`` regression where ``LLVM_UNREACHABLE_OPTIMIZE=OFF``
588 cannot be used with ``Release`` mode builds. (`#68237 <https://github.com/llvm/llvm-project/issues/68237>`_).
589 - Fix crash in evaluating ``constexpr`` value for invalid template function.
590 Fixes (`#68542 <https://github.com/llvm/llvm-project/issues/68542>`_)
591 - Clang will correctly evaluate ``noexcept`` expression for template functions
592 of template classes. Fixes
593 (`#68543 <https://github.com/llvm/llvm-project/issues/68543>`_,
594 `#42496 <https://github.com/llvm/llvm-project/issues/42496>`_)
595 - Fixed an issue when a shift count larger than ``__INT64_MAX__``, in a right
596 shift operation, could result in missing warnings about
597 ``shift count >= width of type`` or internal compiler error.
598 - Fixed an issue with computing the common type for the LHS and RHS of a `?:`
599 operator in C. No longer issuing a confusing diagnostic along the lines of
600 "incompatible operand types ('foo' and 'foo')" with extensions such as matrix
601 types. Fixes (`#69008 <https://github.com/llvm/llvm-project/issues/69008>`_)
602 - Clang no longer permits using the `_BitInt` types as an underlying type for an
603 enumeration as specified in the C23 Standard.
604 Fixes (`#69619 <https://github.com/llvm/llvm-project/issues/69619>`_)
605 - Fixed an issue when a shift count specified by a small constant ``_BitInt()``,
606 in a left shift operation, could result in a faulty warnings about
607 ``shift count >= width of type``.
608 - Clang now accepts anonymous members initialized with designated initializers
610 Fixes (`#65143 <https://github.com/llvm/llvm-project/issues/65143>`_)
611 - Fix crash in formatting the real/imaginary part of a complex lvalue.
612 Fixes (`#69218 <https://github.com/llvm/llvm-project/issues/69218>`_)
613 - No longer use C++ ``thread_local`` semantics in C23 when using
614 ``thread_local`` instead of ``_Thread_local``.
615 Fixes (`#70068 <https://github.com/llvm/llvm-project/issues/70068>`_) and
616 (`#69167 <https://github.com/llvm/llvm-project/issues/69167>`_)
617 - Fix crash in evaluating invalid lambda expression which forget capture this.
618 Fixes (`#67687 <https://github.com/llvm/llvm-project/issues/67687>`_)
619 - Fix crash from constexpr evaluator evaluating uninitialized arrays as rvalue.
620 Fixes (`#67317 <https://github.com/llvm/llvm-project/issues/67317>`_)
621 - Clang now properly diagnoses use of stand-alone OpenMP directives after a
622 label (including ``case`` or ``default`` labels).
629 #pragma omp barrier // ok
636 #pragma omp barrier // error: '#pragma omp barrier' cannot be an immediate substatement
638 - Fixed an issue that a benign assertion might hit when instantiating a pack expansion
639 inside a lambda. (`#61460 <https://github.com/llvm/llvm-project/issues/61460>`_)
640 - Fix crash during instantiation of some class template specializations within class
641 templates. Fixes (`#70375 <https://github.com/llvm/llvm-project/issues/70375>`_)
642 - Fix crash during code generation of C++ coroutine initial suspend when the return
643 type of await_resume is not trivially destructible.
644 Fixes (`#63803 <https://github.com/llvm/llvm-project/issues/63803>`_)
645 - ``__is_trivially_relocatable`` no longer returns true for non-object types
646 such as references and functions.
647 Fixes (`#67498 <https://github.com/llvm/llvm-project/issues/67498>`_)
648 - Fix crash when the object used as a ``static_assert`` message has ``size`` or ``data`` members
649 which are not member functions.
650 - Support UDLs in ``static_assert`` message.
651 - Fixed false positive error emitted by clang when performing qualified name
652 lookup and the current class instantiation has dependent bases.
653 Fixes (`#13826 <https://github.com/llvm/llvm-project/issues/13826>`_)
654 - Fix the name of the ifunc symbol emitted for multiversion functions declared with the
655 ``target_clones`` attribute. This addresses a linker error that would otherwise occur
656 when these functions are referenced from other TUs.
657 - Fixes compile error that double colon operator cannot resolve macro with parentheses.
658 Fixes (`#64467 <https://github.com/llvm/llvm-project/issues/64467>`_)
659 - Clang's ``-Wchar-subscripts`` no longer warns on chars whose values are known non-negative constants.
660 Fixes (`#18763 <https://github.com/llvm/llvm-project/issues/18763>`_)
662 Bug Fixes to Compiler Builtins
663 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
665 Bug Fixes to Attribute Support
666 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
668 Bug Fixes to C++ Support
669 ^^^^^^^^^^^^^^^^^^^^^^^^
671 - Clang limits the size of arrays it will try to evaluate at compile time
672 to avoid memory exhaustion.
673 This limit can be modified by `-fconstexpr-steps`.
674 (`#63562 <https://github.com/llvm/llvm-project/issues/63562>`_)
676 - Fix a crash caused by some named unicode escape sequences designating
677 a Unicode character whose name contains a ``-``.
678 (Fixes `#64161 <https://github.com/llvm/llvm-project/issues/64161>`_)
680 - Fix cases where we ignore ambiguous name lookup when looking up members.
681 (`#22413 <https://github.com/llvm/llvm-project/issues/22413>`_),
682 (`#29942 <https://github.com/llvm/llvm-project/issues/29942>`_),
683 (`#35574 <https://github.com/llvm/llvm-project/issues/35574>`_) and
684 (`#27224 <https://github.com/llvm/llvm-project/issues/27224>`_).
686 - Clang emits an error on substitution failure within lambda body inside a
687 requires-expression. This fixes:
688 (`#64138 <https://github.com/llvm/llvm-project/issues/64138>`_).
690 - Update ``FunctionDeclBitfields.NumFunctionDeclBits``. This fixes:
691 (`#64171 <https://github.com/llvm/llvm-project/issues/64171>`_).
693 - Expressions producing ``nullptr`` are correctly evaluated
694 by the constant interpreter when appearing as the operand
695 of a binary comparison.
696 (`#64923 <https://github.com/llvm/llvm-project/issues/64923>`_)
698 - Fix a crash when an immediate invocation is not a constant expression
699 and appear in an implicit cast.
700 (`#64949 <https://github.com/llvm/llvm-project/issues/64949>`_).
702 - Fix crash when parsing ill-formed lambda trailing return type. Fixes:
703 (`#64962 <https://github.com/llvm/llvm-project/issues/64962>`_) and
704 (`#28679 <https://github.com/llvm/llvm-project/issues/28679>`_).
706 - Fix a crash caused by substitution failure in expression requirements.
707 (`#64172 <https://github.com/llvm/llvm-project/issues/64172>`_) and
708 (`#64723 <https://github.com/llvm/llvm-project/issues/64723>`_).
710 - Fix crash when parsing the requires clause of some generic lambdas.
711 (`#64689 <https://github.com/llvm/llvm-project/issues/64689>`_)
713 - Fix crash when the trailing return type of a generic and dependent
714 lambda refers to an init-capture.
715 (`#65067 <https://github.com/llvm/llvm-project/issues/65067>`_ and
716 `#63675 <https://github.com/llvm/llvm-project/issues/63675>`_)
718 - Clang now properly handles out of line template specializations when there is
719 a non-template inner-class between the function and the class template.
720 (`#65810 <https://github.com/llvm/llvm-project/issues/65810>`_)
722 - Fix a crash when calling a non-constant immediate function
723 in the initializer of a static data member.
724 (`#65985 <https://github.com/llvm/llvm-project/issues/65985>_`).
725 - Clang now properly converts static lambda call operator to function
727 (`#62594 <https://github.com/llvm/llvm-project/issues/62594>`_)
729 - Fixed some cases where the source location for an instantiated specialization
730 of a function template or a member function of a class template was assigned
731 the location of a non-defining declaration rather than the location of the
732 definition the specialization was instantiated from.
733 (`#26057 <https://github.com/llvm/llvm-project/issues/26057>`_`)
735 - Fix a crash when a default member initializer of a base aggregate
736 makes an invalid call to an immediate function.
737 (`#66324 <https://github.com/llvm/llvm-project/issues/66324>`_)
739 - Fix crash for a lambda attribute with a statement expression
740 that contains a `return`.
741 (`#48527 <https://github.com/llvm/llvm-project/issues/48527>`_)
743 - Clang now no longer asserts when an UnresolvedLookupExpr is used as an
744 expression requirement. (`#66612 https://github.com/llvm/llvm-project/issues/66612`)
746 - Clang now disambiguates NTTP types when printing diagnostics where the
747 NTTP types are compared with the 'diff' method.
748 (`#66744 https://github.com/llvm/llvm-project/issues/66744`)
750 - Fix crash caused by a spaceship operator returning a comparision category by
752 (`#64162 <https://github.com/llvm/llvm-project/issues/64162>`_)
753 - Fix a crash when calling a consteval function in an expression used as
754 the size of an array.
755 (`#65520 <https://github.com/llvm/llvm-project/issues/65520>`_)
757 - Clang no longer tries to capture non-odr-used variables that appear
758 in the enclosing expression of a lambda expression with a noexcept specifier.
759 (`#67492 <https://github.com/llvm/llvm-project/issues/67492>`_)
761 - Fix crash when fold expression was used in the initialization of default
763 (`#67395 <https://github.com/llvm/llvm-project/issues/67395>`_)
765 - Fixed a bug causing destructors of constant-evaluated structured bindings
766 initialized by array elements to be called in the wrong evaluation context.
768 - Fix crash where ill-formed code was being treated as a deduction guide and
769 we now produce a diagnostic. Fixes:
770 (`#65522 <https://github.com/llvm/llvm-project/issues/65522>`_)
772 - Fixed a bug where clang incorrectly considered implicitly generated deduction
773 guides from a non-templated constructor and a templated constructor as ambiguous,
774 rather than prefer the non-templated constructor as specified in
777 - Fixed a crash caused by incorrect handling of dependence on variable templates
778 with non-type template parameters of reference type. Fixes:
779 (`#65153 <https://github.com/llvm/llvm-project/issues/65153>`_)
781 - Clang now properly compares constraints on an out of line class template
782 declaration definition. Fixes:
783 (`#61763 <https://github.com/llvm/llvm-project/issues/61763>`_)
785 - Fix a bug where implicit deduction guides are not correctly generated for nested template
787 (`#46200 <https://github.com/llvm/llvm-project/issues/46200>`_)
788 (`#57812 <https://github.com/llvm/llvm-project/issues/57812>`_)
790 - Diagnose use of a variable-length array in a coroutine. The design of
791 coroutines is such that it is not possible to support VLA use. Fixes:
792 (`#65858 <https://github.com/llvm/llvm-project/issues/65858>`_)
794 - Fix bug where we were overriding zero-initialization of class members when
795 default initializing a base class in a constant expression context. Fixes:
796 (`#69890 <https://github.com/llvm/llvm-project/issues/69890>`_)
798 - Fix crash when template class static member imported to other translation unit.
800 (`#68769 <https://github.com/llvm/llvm-project/issues/68769>`_)
802 - Clang now rejects incomplete types for ``__builtin_dump_struct``. Fixes:
803 (`#63506 <https://github.com/llvm/llvm-project/issues/63506>`_)
805 - Fixed a crash for C++98/03 while checking an ill-formed ``_Static_assert`` expression.
806 Fixes: (`#72025 <https://github.com/llvm/llvm-project/issues/72025>`_)
808 - Clang now defers the instantiation of explicit specifier until constraint checking
809 completes (except deduction guides). Fixes:
810 (`#59827 <https://github.com/llvm/llvm-project/issues/59827>`_)
812 - Fix crash when parsing nested requirement. Fixes:
813 (`#73112 <https://github.com/llvm/llvm-project/issues/73112>`_)
815 Bug Fixes to AST Handling
816 ^^^^^^^^^^^^^^^^^^^^^^^^^
817 - Fixed an import failure of recursive friend class template.
818 `Issue 64169 <https://github.com/llvm/llvm-project/issues/64169>`_
819 - Remove unnecessary RecordLayout computation when importing UnaryOperator. The
820 computed RecordLayout is incorrect if fields are not completely imported and
821 should not be cached.
822 `Issue 64170 <https://github.com/llvm/llvm-project/issues/64170>`_
823 - Fixed ``hasAnyBase`` not binding nodes in its submatcher.
824 (`#65421 <https://github.com/llvm/llvm-project/issues/65421>`_)
825 - Fixed a bug where RecursiveASTVisitor fails to visit the
826 initializer of a bitfield.
827 `Issue 64916 <https://github.com/llvm/llvm-project/issues/64916>`_
829 Miscellaneous Bug Fixes
830 ^^^^^^^^^^^^^^^^^^^^^^^
832 Miscellaneous Clang Crashes Fixed
833 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
834 - Fixed a crash when parsing top-level ObjC blocks that aren't properly
835 terminated. Clang should now also recover better when an @end is missing
837 `Issue 64065 <https://github.com/llvm/llvm-project/issues/64065>`_
838 - Fixed a crash when check array access on zero-length element.
839 `Issue 64564 <https://github.com/llvm/llvm-project/issues/64564>`_
840 - Fixed a crash when an ObjC ivar has an invalid type. See
841 (`#68001 <https://github.com/llvm/llvm-project/pull/68001>`_)
842 - Fixed a crash in C when redefined struct is another nested redefinition.
843 `Issue 41302 <https://github.com/llvm/llvm-project/issues/41302>`_
844 - Fixed a crash when ``-ast-dump=json`` was used for code using class
845 template deduction guides.
847 OpenACC Specific Changes
848 ------------------------
849 - OpenACC Implementation effort is beginning with semantic analysis and parsing
850 of OpenACC pragmas. The ``-fopenacc`` flag was added to enable these new,
851 albeit incomplete changes. The ``_OPENACC`` macro is currently defined to
852 ``1``, as support is too incomplete to update to a standards-required value.
853 - Added ``-fexperimental-openacc-macro-override``, a command line option to
854 permit overriding the ``_OPENACC`` macro to be any digit-only value specified
855 by the user, which permits testing the compiler against existing OpenACC
856 workloads in order to evaluate implementation progress.
858 Target Specific Changes
859 -----------------------
863 - Use pass-by-reference (byref) in stead of pass-by-value (byval) for struct
864 arguments in C ABI. Callee is responsible for allocating stack memory and
865 copying the value of the struct if modified. Note that AMDGPU backend still
866 supports byval for struct arguments.
871 - Added option ``-m[no-]evex512`` to disable ZMM and 64-bit mask instructions
873 - Support ISA of ``USER_MSR``.
874 * Support intrinsic of ``_urdmsr``.
875 * Support intrinsic of ``_uwrmsr``.
876 - Support ISA of ``AVX10.1``.
877 - ``-march=pantherlake`` and ``-march=clearwaterforest`` are now supported.
879 Arm and AArch64 Support
880 ^^^^^^^^^^^^^^^^^^^^^^^
882 - C++ function name mangling has been changed to align with the specification
883 (https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst).
884 This affects C++ functions with SVE ACLE parameters. Clang will use the old
885 manglings if ``-fclang-abi-compat=17`` or lower is specified.
887 - New AArch64 asm constraints have been added for r8-r11(Uci) and r12-r15(Ucj).
889 Support has been added for the following processors (-mcpu identifiers in parenthesis):
891 * Arm Cortex-A520 (cortex-a520).
892 * Arm Cortex-A720 (cortex-a720).
893 * Arm Cortex-X4 (cortex-x4).
898 - Android target triples are usually suffixed with a version. Clang searches for
899 target-specific runtime and standard libraries in directories named after the
900 target (e.g. if you're building with ``--target=aarch64-none-linux-android21``,
901 Clang will look for ``lib/aarch64-none-linux-android21`` under its resource
902 directory to find runtime libraries). If an exact match isn't found, Clang
903 would previously fall back to a directory without any version (which would be
904 ``lib/aarch64-none-linux-android`` in our example). Clang will now look for
905 directories for lower versions and use the newest version it finds instead,
906 e.g. if you have ``lib/aarch64-none-linux-android21`` and
907 ``lib/aarch64-none-linux-android29``, ``-target aarch64-none-linux-android23``
908 will use the former and ``-target aarch64-none-linux-android30`` will use the
909 latter. Falling back to a versionless directory will now emit a warning, and
910 the fallback will be removed in Clang 19.
914 - Fixed an assertion failure that occurred due to a failure to propagate
915 ``MSInheritanceAttr`` attributes to class template instantiations created
916 for explicit template instantiation declarations.
918 - The ``-fno-auto-import`` option was added for MinGW targets. The option both
919 affects code generation (inhibiting generating indirection via ``.refptr``
920 stubs for potentially auto imported symbols, generating smaller and more
921 efficient code) and linking (making the linker error out on such cases).
922 If the option only is used during code generation but not when linking,
923 linking may succeed but the resulting executables may expose issues at
931 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
932 aliases ``-m[no-]strict-align``.
934 CUDA/HIP Language Changes
935 ^^^^^^^^^^^^^^^^^^^^^^^^^
943 - Introduced the ``-maix-small-local-exec-tls`` option to produce a faster
944 access sequence for local-exec TLS variables where the offset from the TLS
945 base is encoded as an immediate operand.
946 This access sequence is not used for TLS variables larger than 32KB, and is
947 currently only supported on 64-bit mode.
955 DWARF Support in Clang
956 ----------------------
958 Floating Point Support in Clang
959 -------------------------------
960 - Add ``__builtin_elementwise_log`` builtin for floating point types only.
961 - Add ``__builtin_elementwise_log10`` builtin for floating point types only.
962 - Add ``__builtin_elementwise_log2`` builtin for floating point types only.
963 - Add ``__builtin_elementwise_exp`` builtin for floating point types only.
964 - Add ``__builtin_elementwise_exp2`` builtin for floating point types only.
965 - Add ``__builtin_set_flt_rounds`` builtin for X86, x86_64, Arm and AArch64 only.
966 - Add ``__builtin_elementwise_pow`` builtin for floating point types only.
967 - Add ``__builtin_elementwise_bitreverse`` builtin for integer types only.
968 - Add ``__builtin_elementwise_sqrt`` builtin for floating point types only.
969 - ``__builtin_isfpclass`` builtin now supports vector types.
970 - ``#pragma float_control(precise,on)`` enables precise floating-point
971 semantics. If ``math-errno`` is disabled in the current TU, clang will
972 re-enable ``math-errno`` in the presense of
973 ``#pragma float_control(precise,on)``.
974 - Add ``__builtin_exp10``, ``__builtin_exp10f``,
975 ``__builtin_exp10f16``, ``__builtin_exp10l`` and
976 ``__builtin_exp10f128`` builtins.
977 - Add ``__builtin_iszero``, ``__builtin_issignaling`` and
978 ``__builtin_issubnormal``.
982 - Add ``convertVectorExpr``.
983 - Add ``dependentSizedExtVectorType``.
984 - Add ``macroQualifiedType``.
988 - Add ``AllowBreakBeforeNoexceptSpecifier`` option.
989 - Add ``AllowShortCompoundRequirementOnASingleLine`` option.
990 - Change ``BreakAfterAttributes`` from ``Never`` to ``Leave`` in LLVM style.
991 - Add ``BreakAdjacentStringLiterals`` option.
992 - Add ``ObjCPropertyAttributeOrder`` which can be used to sort ObjC property
993 attributes (like ``nonatomic, strong, nullable``).
998 - Exposed arguments of ``clang::annotate``.
999 - ``clang::getCursorKindForDecl`` now recognizes linkage specifications such as
1000 ``extern "C"`` and reports them as ``CXCursor_LinkageSpec``.
1005 - Added a new checker ``core.BitwiseShift`` which reports situations where
1006 bitwise shift operators produce undefined behavior (because some operand is
1007 negative or too large).
1009 - Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
1012 - Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
1013 to ``unix.StdCLibraryFunctions``.
1015 - Fix false positive in mutation check when using pointer to member function.
1016 (`#66204: <https://github.com/llvm/llvm-project/issues/66204>`_).
1018 - The ``alpha.security.taint.TaintPropagation`` checker no longer propagates
1019 taint on ``strlen`` and ``strnlen`` calls, unless these are marked
1020 explicitly propagators in the user-provided taint configuration file.
1021 This removal empirically reduces the number of false positive reports.
1022 Read the PR for the details.
1023 (`#66086 <https://github.com/llvm/llvm-project/pull/66086>`_)
1025 - A few crashes have been found and fixed using randomized testing related
1026 to the use of ``_BitInt()`` in tidy checks and in clang analysis. See
1027 `#67212 <https://github.com/llvm/llvm-project/pull/67212>`_,
1028 `#66782 <https://github.com/llvm/llvm-project/pull/66782>`_,
1029 `#65889 <https://github.com/llvm/llvm-project/pull/65889>`_,
1030 `#65888 <https://github.com/llvm/llvm-project/pull/65888>`_, and
1031 `#65887 <https://github.com/llvm/llvm-project/pull/65887>`_
1033 .. _release-notes-sanitizers:
1038 - ``-fsanitize=signed-integer-overflow`` now instruments ``__builtin_abs`` and
1041 Python Binding Changes
1042 ----------------------
1044 Additional Information
1045 ======================
1047 A wide variety of additional information is available on the `Clang web
1048 page <https://clang.llvm.org/>`_. The web page contains versions of the
1049 API documentation which are up-to-date with the Git version of
1050 the source code. You can access versions of these documents specific to
1051 this release by going into the "``clang/docs/``" directory in the Clang
1054 If you have any questions or comments about Clang, please feel free to
1055 contact us on the `Discourse forums (Clang Frontend category)
1056 <https://discourse.llvm.org/c/clang/6>`_.