[diff.cpp23.dcl.dcl] (original) (raw)

Annex C (informative) Compatibility [diff]

C.1 C++ and ISO C++ 2023 [diff.cpp23]

C.1.4 [dcl]: declarations [diff.cpp23.dcl.dcl]

Affected subclause: [dcl.decl.general]

Change: Introduction of trivially_relocatable_if_eligible andreplaceable_if_eligible as identifiers with special meaning ([lex.name]).

Rationale: Support declaration of trivially relocatable and replaceable types ([class.prop]).

Effect on original feature: Valid C++ 2023 code can become ill-formed.

[Example 1: struct C {};struct C replaceable_if_eligible {}; — _end example_]

Affected subclause: [dcl.init.list]

Change: Pointer comparisons between initializer_list objects' backing arrays are unspecified.

Rationale: Permit the implementation to store backing arrays in static read-only memory.

Effect on original feature: Valid C++ 2023 code that relies on the result of pointer comparison between backing arrays may change behavior.

[Example 2: bool ne(std::initializer_list<int> a, std::initializer_list<int> b) { return a.begin() != b.begin() + 1;} bool b = ne({2,3}, {1,2,3}); — _end example_]

Affected subclause: [dcl.array]

Change: Previously, T...[n] would declare a pack of function parameters.

Rationale: Improve the handling of packs.

Effect on original feature: Valid C++ 2023 code that declares a pack of parameters without specifying a declarator-id becomes ill-formed.

[Example 3: template <typename... T> void f(T... [1]);template <typename... T> void g(T... ptr[1]);int main() { f<int, double>(nullptr, nullptr); g<int, double>(nullptr, nullptr); } — _end example_]

Affected subclause: [dcl.attr.grammar]

Change: New token :].

Rationale: Required for new features.

Effect on original feature: Valid C++ 2023 code that contained an attribute-specifierwith an attribute-using-prefixbut no attributes and no whitespace is ill-formed in this revision of C++.

[Example 4: struct [[using CC:]] C; struct [[using DD: ]] D; — _end example_]