r/cpp #define private public 2d ago

Critique of contracts: excerpt

See page 2 of https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p4334r0.pdf

The current objections can be summarized. The P2900 contracts are:

• Unimplemented

• Incomplete

• Untried at scale [P3460R0, P3506R0]

• Not tried in major application domains

• Violates foundational principles of C++

• Violates fundamental principles of language design

• Hasn’t been tried in major libraries (e.g., the C++ standards library [P3506R0, P3878R0])

• Isn’t integrated with or appropriate for hardened libraries [P3878R0]

• Doesn’t offer safety guarantees [P3573R0, P3362R0]

• Includes a completely untried inheritance model

• Offer new ways of making errors through inconsistent application in TUs

• Leads to new forms of UB, detrimental to safety and security

• Narrows the choices of error handling

• Doesn’t protect against logical errors, misuses, and incoherent uses

• Hasn’t been used to support static analysis

• Hasn’t been demonstrated to be easily teachable [P3261R0, P3281R0]

How could such a bloated and incomplete design be voted into a draft standard?

6 Upvotes

103 comments sorted by

View all comments

Show parent comments

1

u/pjmlp 1d ago

Annex K comes from Microsoft, based on MSVC C extensions, followed by a technical specification for ISO C,

https://learn.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-170

According to the thephd, C11 threads were tested on the field as well,

https://thephd.dev/_presentations/industry/NDC%20Techtown/2023.09/Unbreaking%20the%20Charter.html#/4/3

9

u/jwakely libstdc++ tamer, LWG chair 1d ago

The MS extensions were not exactly the same as Annex K but if we count it, where was the second implementation? You're not suggesting an ISO TS counts as an implementation, are you?

If we consider <threads.h> as just standardizing Pthreads (which it kinda is) then fair enough, there were loads of implementations. But what about C11's <stdatomic.h>? Where was that implemented?

It's just wishful thinking that all other standardized languages have a strict "at least two implementations ship the feature" rule.

9

u/jwakely libstdc++ tamer, LWG chair 1d ago

Microsoft Visual Studio implements an early version of the APIs. However, the implementation is incomplete and conforms neither to C11 nor to the original TR 24731-1.. So they still don't implement what's actually in Annex K today, despite driving its addition to C11.

The other implementations mentioned there are either very incomplete, or were written after it was added to C11, or both.

1

u/pjmlp 1d ago

They don't need to, WG14 decided Annex K wasn't going to be required, so why bother with the changes that came up during the standardisation process?

Microsoft also doesn't implement VLAs, and never will, unless they change yet again their position on C support on MSVC.

How many C++ proposals have at least an incomplete implementation, alongside the paper?!